1,json data format
The code is as follows |
Copy Code |
Background program return string {' message ': ' Hello word '} The front desk resolves this var dictionary=eval ("(" + Data + ")"); Background program return string ({' message ': ' Hello word '}) The front desk resolves this var dictionary=eval (data); $.ajax ({ URL: "Getjosnstring", Type: "Post", DataType: "JSON", Success:function (data) { var msg = eval (data); alert (msg.message); Output the result Hello word } }); |
2.each Loop Object json
Background definition string
The code is as follows |
Copy Code |
({' message ': ' Hello word ', ' Msg ': ' Hello word '}) ({' Items ': [{' message ': ' Hello word ', ' Msg ': ' Hello word '}]} $.ajax ({ URL: "Getjosneach", Type: "Post", DataType: "JSON", Success:function (data) { var datas = eval (data); /*********** first read the dictionary type *************** $.each (datas, function (key, value) { Alert (key + ":" + value); Message:hello Word }); *************************/ The second method of parsing a string $.each (datas. Items, function (key, value) { Alert (key + ":" + value. MSG); 0:hello the first element and value in a word value }); } }); |
Above also casually introduced jquery each object everybody is interested can look for oneself, here only is simple uses