Jquery Multiple ajax call

故事扮演 提交于 2019-12-24 21:32:50

问题


I have a listed navigation with letters and i am trying to call the actors and directors from different json files when the user clicked a letter. I used 2 ajax calls to get the data from actor.php and director.php. It works fine on my local machine, but only the first one works on server. How can i make each ajax calls working?

$(document).ready(function(){
    $('.letters').click( function(){
         var letter=$(this).html();

     $.ajax({
       url: 'actor.php?harf='+letter,
       dataType: 'json',
       success: function(JSON) 
                 {  //some code   }
               }); 


     $.ajax({
       url: 'director.php?harf='+letter,
       dataType: 'json',
       success: function(JSON) 
              {  // some code     }
     }); });  });

回答1:


What happens if you do this:

$.ajax({
   url: 'actor.php?harf='+letter,
   dataType: 'json',
   success: function(JSON) {  
     //some code   
     $.ajax({
       url: 'director.php?harf='+letter,
       dataType: 'json',
       success: function(JSON) {
         // some code
       }
     });
   });
});

Piling up 2 ajax invocations back-to-back is not something I would risk.




回答2:


it loads when i load director.php?harf=xxx from web browser. just the second ajax call doesnt work when i try to get 2 json file with 2 ajax call.




回答3:


        $.ajax({
            "type": "POST",
            "dataType": 'json',
            "contentType": "application/json; charset=utf-8",
            "url": "../webmethods.aspx/UpdateNextFollowUpForMultipleInvoice",
            "data": "{'strIds':'" + strIds + "','dtNextFollowUp':'" + dtNextFollowUp + "'}",
            "success": function () {


            }
        });


来源:https://stackoverflow.com/questions/2576082/jquery-multiple-ajax-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!