开发者

Finding the Server Redirects as a result of a jQuery Post

I would like to post a serialized form like the one in the following url http://api.jquery.com/jQuery.post/

And i need to figure out whether there is a redirect, if the application to which i post the data has been timed out [auto logoff] from jquery,

so i would like to have like this

$.post("getData", serializedForm, function(data){
process(data);},
statusCode:{
    302 : 
        { function()
             {
    alert("your 开发者_JS百科request has been timed out, re-login to continue further");
             }
         }
 });

This kind of code is not working.. any workarounds in this case. Also suggest me a suitable way to find redirects when i request data using $.getJSON from jQuery.


You've got your synthax messed up. Try this:

$.post("getData", serializedForm, function(data, textStatus){
    if (textStatus === 302) {
        alert("your request has been timed out, re-login to continue further");
        return;
    }
    process(data);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜