I'm trying to retrieve json item data from an Ajax call which returns both html and json. My javascript below returns a success message, which is helpful; I'm just not sure how to access the data. I'm trying to access newPrice
from this response:
Data Loaded: <pre>Array
(
[point] => 86
[claimId] => 3594
[type] => yeh
)
</pre>{"data":{"newPrice":88,"lockedInPrice":86},"errors":[],"success":true,"code":200}
My code is below. I'm specifically trying to return only the newPrice value:
var newData = $.ajax({
type: "POST",
url: takeurl,
dataType: "html",
data: { point: point, claimId: id, type: val }
})
.success(function(data) {
alert("Data Loaded: " + data);
//newPrice = data.newPrice; -- returned undefined?
console.log(newPrice);
})
.error(function() { alert("not yet"); })
.complete(function(data) {
console.log('complete 1' );
});
// Set another completion function for the request above
newData.complete(function(data){
console.log("second complete" );
});
return false;
});
Thank you!