i want to get amount value from following json response how to get
Object {readyState: 4, responseText: "{"amount":1231,"firstName":"dfsdf","lastName":"lasernmae","email":"vijaitest@gmail.com"}", status: 200, statusText: "OK"}
complete: function(response) { var jsonObject = $.parseJSON(response); console.debug(jsonObject.responseText.amount); }
for above coding i am getting Uncaught SyntaxError: Unexpected token o.
var data = '{"readyState": 4, "responseText": {"amount":1231,"firstName":"dfsdf","lastName":"lasernmae","email":"vijaitest@gmail.com"}, "status": 200, "statusText": "OK"}';
var jsonObject = $.parseJSON(data);
console.debug(jsonObject.responseText.amount);
if you have responseText as String you can use following code:
var resT = $.parseJSON(response.responseText);
console.debug(resT.amount);
Assuming your object has the variable name of data. Just do..
var amount = data.responseText.amount;
If you are getting that response from a server, and still need to parse it.
var data = JSON.parse(theObjectsVariableNameHere);
var amount = data.responseText.amount;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.