1

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.