0

我有一个带有字母的列表导航,当用户单击一个字母时,我试图从不同的 json 文件中调用演员和导演。我使用了 2 个 ajax 调用从 actor.php 和 director.php 获取数据。它在我的本地机器上运行良好,但只有第一个在服务器上运行。如何使每个 ajax 调用正常工作?

$(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     }
     }); });  });
4

3 回答 3

3

如果你这样做会发生什么:

$.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
       }
     });
   });
});

背靠背堆积 2 个 ajax 调用并不是我愿意冒险的事情。

于 2010-04-05T00:16:33.620 回答
0

当我从网络浏览器加载director.php?harf=xxx 时它会加载。当我尝试使用 2 个 ajax 调用获取 2 个 json 文件时,只是第二个 ajax 调用不起作用。

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


            }
        });
于 2013-05-17T04:20:46.313 回答