Json string is returned back
[{
"XXX": "111 ",
"YYY": "222"
}, {
"XXX": "222",
"yyy": "3333"
}]
After reception json ajax request string to the background, it is processed, there may be success: function (result)
Inside the result returned string, for var obj = eval ( '(' + result + ')');
This way, JSON string returned result is transformed into the object obj,
Then obj [0] Gets { "XXX": "111", "YYY": "222"}
obj[1]获取{"XXX":"222","yyy":"3333"}
obj[0].length = 2
obj[1],length = 2
It can be dealt with.
Meanwhile, if you want to put this json object is passed js onclick = function (obj) to go inside,
What needs to be processed before it can pass into the var temp = encodeURI (JSON.stringify (obj [0]));
After such treatment, into the function, and then decode it,
function(list)
var temp = JSON.parse(decodeURI(list));
This way you can inside a function, get a json objects.
Record a problem encountered what I hope next time you come across, can improve efficiency, the fast processing.