'how to retrieve json encoded multi dimension in php with javascript in ajax call
i received json as
[[{"tid":"1","sid":"1","tname":"Classical Mechanics"}],[{"examid":"1","sname":"Physics","ename":"CSIR-NET"},{"examid":"2","sname":"Physics","ename":"GATE"}]]
i need to get each item as array. i tried
success: function(msg){
console.log(msg);
for (var j in msg[0]) {
$('#tctop').append(" <option value="+msg[0][j]['sid']+">"+msg[0][j]['tname']+"</option>")
}
for (var j in msg[1]) {
$('#tcexm').append(" <option value="+msg[1][j]['examid']+">"+msg[1][j]['ename']+"</option>")
}
}
but it did not works.
for a try i defining
var msg=[[{"tid":"1","sid":"1","tname":"Classical Mechanics"}],[{"examid":"1","sname":"Physics","ename":"CSIR-NET"},{"examid":"2","sname":"Physics","ename":"GATE"}]]
and use the loop it worked. How to get a result when you receive response from ajax call
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
