I have a JSON result after Ajax as following
{
"results": [
{
"id": " 14903",
"nsid" : "10438",
"name": "001-2501220",
"label":"001-2501220 End Seal",
"price":"12.6"
},
{
"id": " 14904",
"nsid" : "10439",
"name": "001-2501231",
"label":"001-2501231 Poppet",
"price":"12.3"
},
{
"id": " 14917",
"nsid" : "3391",
"name": "PW16001",
"label":"PW16001 Caliper Piston 38.1mm Lucas TRW handbrake",
"price":"26.5"
}
]}
I am facing difficulties reading this. I have tried as
$.ajax({
type: "POST",
url: url,
data: "partnumber=" +value,
cache: false,
success: function(data){
console.log(data);
for (var i in data.results) {
var name = data.results[i].name;
var text = data.results[i].label;
console.log(name);
console.log(text);
}
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
But no luck.