I'm using codeigniter. Following is my AJAX code in view -
jQuery(document).ready(function () {
$.ajax({
type:'post',
data:'',
url:HOST+'/exp1',
success:function(data)
{
alert('here1')
}
});
setInterval(function(){
$.ajax({
type:'post',
data:'',
url:HOST+'/exp2',
success:function(data)
{
alert(data)
}
});
}, 1000);
});
And the controller code is -
function exp1()
{
sleep(10);
}
function exp2()
{
echo 'test';
}
Above both ajax calls are independent but on same controller. First ajax takes 10 seconds to get response, while second ajax will take 1 second to get response.
Second ajax request is fired after every 1 second.
But when i execute the code, i did not get the response from the second ajax until to be get first ajax response.
How can i drive both ajax simultaneously so that i'll get response from second ajax while first ajax call will be in process ?