weixin_33735077 2016-11-22 07:19 采纳率: 0%
浏览 9

Ajax请求问题

I have a html form to make an order in a shop by clicking a button called Order.(button_id="order") At the button click event i have performed a ajax request to a page(itemOrder_php2.php) which sends some data in the form to that mentioned page. It's working correctly. But the problem is ajax request is not functioning when two or more users order at the same time. Please help me to work with multiple ajax requests. Thank you! here is my code.

  $(document).ready(function(){
  $("#order").click(function(e){
      e.preventDefault();                    
    $.ajax({type: "POST",
            url: "itemOrder_php2.php",
            data: { selectedItem: $("#selectedItem").val(), sizeUnit: $("#sizeUnit").val(), quantity: $("#quantity").val(), value: x, lSize : $("#lSize").val(), lPrice : $("#lPrice").val() },
            success:function(result){  
      $("#orderResult").html(result);               
    }});  
  });
});
  • 写回答

1条回答 默认 最新

  • weixin_33696822 2016-11-22 07:26
    关注

    Handle the click event with document on...

    $(document).ready(function(){
      $(document).on('click','#order',function(e){
         e.preventDefault();                    
    
        $.ajax({type: "POST",
                url: "itemOrder_php2.php",
                data: { selectedItem: $("#selectedItem").val(), sizeUnit: $("#sizeUnit").val(), quantity: $("#quantity").val(), value: x, lSize : $("#lSize").val(), lPrice : $("#lPrice").val() },
                success:function(result){  
          $("#orderResult").html(result);               
        }});  
      });
    });
    
    评论

报告相同问题?