The exact way of adding item to the Cart is like follows its an ajax call function
var data = "quantity[]="+qty+"&virtuemart_product_id[]="+pid
//data = encodeURIComponent(data);
jQuery.ajax({
type: "GET",
dataType: 'json',
url: "index.php?option=com_virtuemart&nosef=1&view=cart&task=addJS",
data: data,
success: function(data) {
alert(data);
}
});