how to use jquery ajax array post json?

后端 未结 3 1716
走了就别回头了
走了就别回头了 2021-01-26 17:59

i want to send array in ajax json post ,but some code are error.how to fig this code?

HTML

 
相关标签:
3条回答
  • 2021-01-26 18:05

    Don't use if(clickHandler) style syntax, that will never trigger when you want it to, instead just define the click handler:

    $('#save-menu').click(function() {
        //do stuff on save-menu click
    })
    
    0 讨论(0)
  • 2021-01-26 18:13

    Bind an event handler to the "click" JavaScript event, or trigger that event on an element.

    $( "#save-menu" ).click(function() {
       //Handler for .click() called. 
       $.post('menu/order',{...});
    });
    
    $( "#calculator" ).click(function() {
       //Handler for .click() called. 
       $.post('menu/calculator',{...});
    });
    
    0 讨论(0)
  • 2021-01-26 18:14

    It's the way you have the click events set up that are causing you your problems. It should look more like this:

    $('#save-menu').click(function() {
      $.post(... ajax stuff...);
    });
    
    0 讨论(0)
提交回复
热议问题