My requirement is ,I have written lots of $.post method in my project. I want to check the session in every request and depending upon the session value, I want to handle my page.But I don`t want to modify all methods($.post) for session, So I want to check the session in "ajaxStart or ajaxSend" and depending upon the response I want to abort the main AJAX call.
I have tried with my little knowledge.The below sample code is not working,because $.post is asynchronous.Could any one help me to abort an AJAX Request in ajaxStart or ajaxSend state?
var pp;
link=function(id){
var url="http://localhost/jqueryui/test.php";
pp=$.post(url,{"id":id},function(data){
$("#div"+id).html(data);
});
}
$(function(){
$("#loading").ajaxStart(function(){
alert("Hi start");
$(this).show();
var url="http://localhost/jqueryui/test.php";
$.post(url,{"id":99},function(data){//checking the session
if(data == "close")
pp.abort();
});
});
});