第二次jquery ajax调用不起作用?

时间:2013-03-13 16:43:51

标签: ajax jquery

我看不出我做错了什么。第二个ajax调用不起作用,就像第一个

一样
     $(".payment").click(function(){
     visitorID = $(this).attr('id');
     alert("Modal says "+visitorID);
     $.ajax({ url: 'update.php',
         data: {action: visitorID},
         type: 'post',
         success: function(output) {
                      alert(output);
                      window.location.reload(); //reload so we see the updated values

                  },
        });     
});//#end click
$(".generateInvoice").click(function(){
     barcode = $(this).attr('barcode');
    alert("Modal says "+barcode);
     //console.log('hello');
     $.ajax({ url: 'generateInvoice.php',
         data: {action: barcode},
         type: 'post',
         success: function(output) {
                      alert('hi '+output);
                     //console.log('hie');
                      //window.location.reload(); //reload so we see the updated values

                  },
        });     
});//#end click

付款时我会看到两个警告框,但是使用generateInvoice我只能看到第一个警告框。出于测试目的,我已经生成了generateInvoice.php,只需阅读

echo ' there does it work';
die();

但是使用.generateInvoice,$ .ajax中的警报不显示

任何信息?

1 个答案:

答案 0 :(得分:0)

tx思考,但我发现了我的愚蠢错误。

在HTML中,按钮标签没有声明类型,所以我添加了

type="button" 

现在正在触发/调用ajax部分:)

因为第一个警告显示它并没有让我想到

问候