目前,您的 jQuery 代码在文档已准备就绪的处理器中, 所以( 显然) 它会在文档准备好后立即运行 - 与您的 Ajax 调用完全无关的时间。 相反, 将您的 jQuery 代码放在自己的函数中, 在设置 < code> abj code > 后立即调用它。 或者直接移动 jQuery 代码到您设置 < code> abj code > 的函数中 :
var json_data = http_request.responseText;
obj = eval("(" + json_data + ")");
//at this point I have the information I want in "obj"
// either process obj directly here, or call a function to do it...
processData(obj);
...
function processData(obj) {
// your jQuery code here, using obj
}
不过,既然你正在使用jQuery, 最好还是用 http://appi.jquery.com/cortion/ajax/"rel="nofollow" 来做Ajax, jjax 函数 。 我建议使用 http://api.jquery.com/jQuery.getJson/"rel="nofolp"\\\\\code>$.getJson() 。
$.getJSON("yourURLhere", function(obj) {
// your jQuery code using obj here
});