Simulating data in a background request path
var result =[ {' Shop ': ' s001 '}, {' shop2 ': ' s002 '} ]
For example: is displayed on the page s001 on behalf of Shanghai stores, S002 representative Guanzhou store, the front-end how to deal with this data?
First, the store represents only the object of the form listed var Dianpu = { ' s001 ': ' Shanghai Shop ', ' s002 ': ' Guangzhou Shop '}
function data (Result) {for (var i = 0;i<result.length;i++) { var shopdata = result[i].shop//s001 s002 Console.log (Dianpu[shopdata])//Shanghai store in Guangzhou to obtain the Console.log (dianpu[' s001 ']) }}data (Result)
The JSON object that we requested can be handled as follows: $.each ()
For example: var obj = [ { ' name: ' Judy ', ' age ': ' + ' , ' major ': ' Web Front end ' }, { ' name: ' Wayne ', ' a GE ': ' + ', ' major ': ' PHP front ' }]$.each (obj,function (index,data) { console.log (' index: ' + index + ', Name: ' + Data.name+ ' age ' +data.age+ ' Major ' +data.major)})
Output result: Index:0,name:judy Age:18,major:web front End
Request to JSON data processing