how to send multiple data with $.ajax() jquery

后端 未结 9 1506
臣服心动
臣服心动 2020-11-27 03:07

i am trying to send multiple data using j query $.ajax method to my php script but i can pass only single data when i concatenate multiple data i get undefined index error i

相关标签:
9条回答
  • 2020-11-27 03:37
    var my_arr = new Array(listingID, site_click, browser, dimension);
        var AjaxURL = 'http://example.com';
        var jsonString = JSON.stringify(my_arr);
        $.ajax({
            type: "POST",
            url: AjaxURL,
            data: {data: jsonString},
            success: function(result) {
                window.console.log('Successful');
            }
        });
    

    This has been working for me for quite some time.

    0 讨论(0)
  • 2020-11-27 03:39
      var value1=$("id1").val();
      var value2=$("id2").val();
        data:"{'data1':'"+value1+"','data2':'"+value2+"'}"
    

    You can use this way to pass data

    0 讨论(0)
  • 2020-11-27 03:43

    I would recommend using a hash instead of a param string:

    data = {id: id, name: name}
    
    0 讨论(0)
提交回复
热议问题