result = jQuery.parseJSON(result);
for(var k in result)
{
alert(k);
alert(result[k]);
}
This code is working just fine.
But let's suppose I'm receiving object of the following type
status='FALSE'
message='error'
If you want to echo all this things first code is ok. It will alert everything. But what If I want to work with this data, do some manipulations. In this case this for loop is a bit bad idea for me. So I have to transform probably this data into something new. Maybe constract some array during this loop and then read from array ? I think there must be some simple way to get access to that data. Please help
If result is JSON data, you should be able to simply do:
result = jQuery.parseJSON(result);
alert(result.status);
alert(result.message);
pareJSON turns the JSON data into a JavaScript Object. To access properties of an Object in JavaScript, you need to use dot notation.
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.