Use ajax written natively in js to obtain a data list, and the order is normal
xmlHttp.responseText The order here is normal
But when I convert the json string into a json object, the order is not the original order
var json = eval('(' + xmlHttp.responseText + ')');
Is there any way to maintain the original output order after conversion?
phpcn_u15822017-05-19 10:40:41
I don’t quite understand, what do you mean? Has the data order changed? ?
Actually, there are several ways toJson, you can try them all.
// 1
function toJson(json){
return json ? (new Function("return "+ json))() : {}
}
toJson(xmlHttp.responseText)
// 2
JSON.parse(xmlHttp.responseText)
// 3 就是你那种