Reputation: 6639
I am passing data from php in json format, how do I access it?
This is the result:
{"solctype":"Long Term Agreement","checkbox":"1","prnumber":"356363563"}
I have tried
$.post("getgrid?id="+id,
{
},
function(data, status){
console.log(data.solctype);
});
This always returns undefined
Upvotes: 1
Views: 30
Reputation: 3856
You need to parse the string data and convert it to a JavaScript object.
Use something like this:
var stringData = {"solctype":"Long Term Agreement","checkbox":"1","prnumber":"356363563"};
var parsedData = JSON.parse(stringData);
console.log(parsedData.solctype)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
Upvotes: 1