我想高度解释一下我的问题是什么,因为我无法提供过于复杂的完整代码。
我有一个按钮。当我点击按钮时,它从fb中提取数据并解析它并将其添加到页面中。现在加载到页面之后..我想在加载的内容上运行脚本。我在解析数据后运行脚本,但不知何故它显示该脚本开始运行时没有加载该元素。有人可以投光。
$("somebutton").on("click",function(){
LoadAndParseFbData();
});
function LoadAndParseFbData(){
//loaded the json, parsed it and added to the page.
anotherScript();
}
function anotherScript(){
// this has some script related to data which is loaded dynamically by parsing json.
}
这就是我在高水平上的尝试。请帮助谢谢:)
答案 0 :(得分:1)
$("somebutton").on("click",function()
LoadAndParseFbData();
});
function LoadAndParseFbData(){
FB.api(path, method, params, function(){
//loaded the json, parsed it and added to the page.
anotherScript();
});
}
function anotherScript(){
// this has some script related to data which is loaded dynamically by parsing json.
}
答案 1 :(得分:0)
从ajax成功回调中运行anotherScript()
:
$J.ajax({
url: url2,
type: "post",
data: { data: "yourdata", },
success: function (data, textStatus, jqXHR) {
anotherScript();
},
error: function(jqXHR, textStatus, errorThrown) {
/*error handling code here*/
}
});