this is javascript..........
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function product() {
this.Id = "";
this.brand = "";
this.model = "";
this.image = "";
this.price = "";
this.stock = "";
this.offer = "";
this.website = "";
this.url = "";
}
jQuery.ajax({
type: "GET",
url: "http://api.pricecheckindia.com/feed/product/mobile_phones.json?user=headboy6&key=BNTLMKXUHBKQJGUY",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
crossOrigin: true,
async: true,
success: function (response) {
// console.log(response.product);
var dataToSend = new Array();
//var mydata = dataToSend;
$.each(response.product, function (index, Value) {
var p = new product();
p.Id = response.product[index].id;
p.brand = response.product[index].brand;
p.model = response.product[index].model;
var stores = response.product[index].stores;
$.each(stores, function (index, Value) {
if (index === 0) {
p.image = stores[index].image,
p.price = stores[index].price,
p.stock = stores[index].stock,
p.offer = stores[index].offer,
p.website = stores[index].website,
p.url = stores[index].url
}
})
dataToSend.push(p);
});
console.log(dataToSend);
Send(dataToSend);
},
error: function (msg) {
console.log(msg);
alert(msg)
}
});
function Send(d) {
var mydata = { product: d };
jQuery.ajax({
url: "/Home/Test",
type: "POST",
dataType: "json",
data: mydata,
//dataType: "xml",
// contentType: "application/json; charset=utf-8",
async: false,
cache: false,
success: function (data) {
alert(data);
console.log(product);
},
error: function (errMsg) {
alert(errMsg);
console.log(errMsg);
}
});
}
</script>
controller is
[HttpPost]
public ActionResult Test(string[] Product)
{
return View();
}
plz help me
thanks