[英]how to read json response in javascript
i have a json object in response, using that i have to create a jstree. 我有一个json对象作为响应,使用它我必须创建一个jstree。 But not able to read that json object in javascript function. 但无法在javascript函数中读取该json对象。
My JavaScript: 我的JavaScript:
var repoId = $('#frmHdnV').val();
// variable to hold request
var request= $.post("CreatJqueryTree",{repoId:repoId},function(data){},"json");
request.done(function (response, textStatus, jqXHR){
alert(response);
var tem = JSON.parse(response);
var obj = tem.data;
$("#tes").jstree({
"json_data" : {
"data" : // here i need that json object to create this tree
},
"plugins" : [ "themes", "json_data", "checkbox", "ui" ]
}).bind("select_node.jstree", function (e, data) { alert(data.rslt.obj.data("id")); });
});
request.fail(function (jqXHR, textStatus, errorThrown){
alert("....Not Done...");
alert(errorThrown);
});
the Response i can see in the firefox usinhg firebug. 我在firefox usinhg萤火虫中看到的响应。 but how to read that json object from response. 但是如何从响应中读取该json对象。
Try this: 尝试这个:
$.post("CreatJqueryTree",{repoId:repoId},function(data){
$("#tes").jstree({
"json_data" : {
"data" : data
},
"plugins" : [ "themes", "json_data", "checkbox", "ui" ]
}).bind("select_node.jstree", function (e, data) { alert(data.rslt.obj.data("id")); });
},"json");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.