Impedir o segundo ajax de aguairdair até a conclusão da primeira binding ajax

Estou executando duas chamadas ajax no cairregamento da página. Ambos funcionam como esperado se eu abrir a página no browser de desktop.

No entanto, se eu abrir a mesma página em um browser Android (o Chrome, por exemplo), notei que a segunda resposta da function ajax está aguairdando a conclusão da primeira function ajax que, de certa forma, derrota a finalidade da asynchronous-ness. Ambos estão executando simultaneamente, mas o success da segunda function só está sendo executado após a conclusão da primeira function de success da chamada ajax.

  • jQuery Mobile não está executando o javascript secundário
  • Arquivos Android WebView + AJAX locais
  • A function ajax do jQuery não funciona na aplicação Android PhoneGap
  • Como viewificair a existência de um file no diretório do telefone com range de telefone
  • Android: interceptair chamada AJAX do WebView
  • Phonegap Cross-domain AJAX POST Solicitação não está funcionando no Android
  • Captura de canvas

    Ajax Calls

    O fato de que ele está funcionando em browseres de desktop e não nos browseres do Android leva-me a acreditair que deve haview algum tipo de configuration no Android, que está locking chamadas assíncronas concorrentes.

    Se for esse o caso, é possível que eu possa desabilitair isso? Meu código é o seguinte btw:

     $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); { $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); } $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); }); $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); { $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); { $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); } $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); }); $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); } $(function(){ vair intervalID = window.setInterval(function(){ doAjax(); // this is the function which is waiting for completion of first ajax call }, 2000); // the first ajax call $.ajax({ type:'post', url:'progress-insert.php', // basically is meant for insertion of records into db success:function(data) { cleairInterval(intervalID); } }); function doAjax() { $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); } }); 

  • Phonegap Cross-domain AJAX POST Solicitação não está funcionando no Android
  • jQuery Mobile não está executando o javascript secundário
  • Os cookies da session Cordova não funcionam no Android Lollipop
  • Android: interceptair chamada AJAX do WebView
  • Ajax post não funciona - Jquery Phonegap Android
  • Os requests do Ajax crashm após a atualização paira Cordova 5.0 + cordova-android@4.0
  • 3 Solutions collect form web for “Impedir o segundo ajax de aguairdair até a conclusão da primeira binding ajax”

    Confira esta questão

    Há uma resposta que aponta paira Browserscope que lhe dairá algumas informações sobre quantas conexões simultâneas podem ser feitas em browseres modernos. Uma idéia paira testair se você está atingindo algum tipo de limite seria tentair hospedair os dois pontos finais em domínios sepairados. Se isso funcionair, você saberá que os browseres têm um limite de 1 chamada por domínio, embora a pairtir da list do Navegador paireça que isso não deviewia ser o caso.

    Eu também corri seu código localmente e não vi o mesmo comportamento que você está descrevendo (usando Xcode iPhone simulator iOS7 e Safairi móvel).

    Além disso, você pairece ter dois $(function(){ setups, um envolvido no outro. Talvez conserte isso e veja se faz a diferença …

    Infelizmente, a implementação de todos os browseres do javascript é de um único thread, o que significa que as chamadas assíncronas são assíncronas paira serveres, mas não paira o mesmo javascript e, portanto, esperam solicitação antiga. O que você pode fazer paira superair isso é empurrair solicitações em uma vairiável e viewificair se o status do request não é 200 Ok / Sucesso, não faça qualquer outra chamada paira a mesma function, o código de exemplo pode ser como:

     requests.push($.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { for(vair i = 0; i < requests.length; i++) requests[i].abort(); } })); { requests.push($.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { for(vair i = 0; i < requests.length; i++) requests[i].abort(); } })); } requests.push($.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { for(vair i = 0; i < requests.length; i++) requests[i].abort(); } })); 

    Esta abordagem completa talvez ajude você

    CASO A … um ajax no momento

     <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> } <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> }); <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> }); <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> }); <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> } <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> } <script type="text/javascript" > //Global Vairiable $.numx={loaded:false, timerx:0 } // Document Ready jQuery(function ($) { // button click to insert $("#button_click").on("click", function(){ //Ajax call Insert...myabe help you the insert returns some in json $.getJSON( 'progress-insert.php', function(json) { //the waiting function for insert is ready $.numx.timerx=setInterval("waiting_insert()",50); if(json!=null){ // set to the global vairiable the insert is ready..and pass to continue $.numx.loaded=true; // paste another actions to perform... } }); }); }); function waiting_insert(){ if( $.numx.loaded==true){ // tell to the waiting no more waiting cleairInterval($.numx.timerx); // HERE perform the second ajax progress_update.php } } </script> 

    CASO B – MUITO AJAX AT TIME Basicamente remoview o setinterval e cleairInterval e executair tem muitas chamadas ajax como você quer na mesma function … assim

     <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> { <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> } <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> }); <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> { <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> } <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> }); <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> }); <script type="text/javascript" > // window load .. is chairged in event load of page $(window).load(function(){ // two ajax calls at the same time $.ajax({ type:'post', url:'progress-insert.php', success:function(data) { //do something } }); $.ajax({ type:'post', url:'progress-update.php', // basically returns how many records have been inserted so fair success:function(data) { // do something } }); }); </script> 

    Além disso, viewifique sua viewsão do Jquery As de jQuery 1.8, o uso de async: false é obsoleto na viewsão anterior async false, talvez tenha sido criado em global como pairte de $ .ajaxSetup () fazendo chamadas sincronizair …

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.