日期:2014-05-17 浏览次数:20940 次
$.ajax({
type: "POST",
url: "/CPSolution/allResourceAction.html",
dataType:"html",
data: {"menuNumber":index},
success: function(data){
initiate();// ajax提交返回成功之后调init方法
},
error:function(){
alert($("#content" + i)+"加载失败");
}
});
------解决方案--------------------
$.post(url,参数, function (result,type) { ...处理你要做的事情...});
------解决方案--------------------
ajax回调
------解决方案--------------------
楼上都说的差不多,就是写一个回调函数,然后在回调函数中完成自己所要实现的代码。
如下:
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
if(trim(xmlHttp.responseText) != ""){
document.getElementById("spanClientId").innerHTML = "<font color='red'>" + xmlHttp.responseText + "<font>";
}else{
document.getElementById("spanClientId").innerHTML = "";
}
}else{
alert("请求失败,错误码=【" + xmlHttp.status + "】");
}
}
};
------解决方案--------------------
initiate()把这个方法放到ajax的回调函数里面处理