开发者

jquery ajax inside another ajax request

开发者 https://www.devze.com 2023-01-23 06:37 出处:网络
Here is some javascript/jquery code: $(\'#button\').click(function() { $.get(\"php/doit.php?id=<? echo $r[\'id\']; ?>\", function(html)

Here is some javascript/jquery code:

$('#button').click(function()
{
     $.get("php/doit.php?id=<? echo $r['id']; ?>", function(html)
     {
         alert(html);

         // $.get("php/doit.php?id=<? echo $r['id']; ?&g开发者_运维技巧t;", function(html)
         // {
               // alert('omg!');
         // }

     });
 });

The second ajax request should be called when the first is completed, right? The above code works great, but as soon as I uncomment the second request, the whole javascript block fails - I dont even get the 'alert' anymore. Even if you put an alert just to test the .click it does not work.

Is there something that I should be clearing after ajax requests? Why exactly can I NOT make 2 requests?

Thanks


You are missing ); for the second .get. It's just a syntax error.

0

精彩评论

暂无评论...
验证码 换一张
取 消