开发者

Send a javascript array to server using JQuery

开发者 https://www.devze.com 2023-03-24 05:13 出处:网络
I want to send this array: results = [1, 4, 5, 6] So, I\'m using this call: $.ajax({ url: \'save_record\',

I want to send this array:

results = [1, 4, 5, 6]

So, I'm using this call:

$.ajax({
        url: 'save_record',
        type: 'POST',
        data: JSON.stringify({ sheets: results }),
        dataType: "json",
        success : function (data) {
            // Code here
        }
    });

But my PHP file is not receiving any parameter :( Wha开发者_如何学Got is wrong?


$.ajax({
        url: 'save_record',
        type: 'POST',
        data: {sheets:JSON.stringify(results)},
        dataType: "json",
        success : function (data) {
            // Code here
        }
    });


$.ajax({
    url: 'save_record',
    type: 'POST',
    data: {
        sheets: results 
    },
    dataType: "json",
    success : function (data) {
        // Code here
    }
});
0

精彩评论

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