i´m calling a function that loads content via AJAX (ajax.load_mainmenu). When that´s done i want to do some other stuff. I can´t call it on "success" directly so i need to do it AFTER the request is finished. How can i do that?
ajax.load_mainmenu(data).function()
{
// Some other function开发者_StackOverflow社区s
}
if(ajax.load_mainmenu(data))
{
// Some other functions
}
Forgive me my stupid approaches. Still learning ;). I could pass a reference to another function to my AJAX-function (called on "success"), but it seems a bit to overcomplicated to me.
simple :
you should use the callBaCK FUNCTION .
jQuery.ajax(
{
type: "POST",
url: '../Handler/HandlerSaveSelector.ashx?tId=5' ,
dataType: 'json', //expecting data xml , html , script , json ,
contentType:"application/json; charset=utf-8",
data: $.toJSON(jsonObj), //e.g. "{'fname':'dave','lname':'ward'}"
cache: false,
success: function(result)
{
if (result.isOk == false) alert(result.message);
else
{
log(" finish SaveSelectorsToDB");
}
},
async: true
});
精彩评论