【问题标题】:How to submit data to server using jquery post如何使用 jquery post 向服务器提交数据
【发布时间】:2012-06-27 13:44:08
【问题描述】:

我正在使用 jquery post 在服务器上提交数据,并且数据具有 json 数组作为其中一个值。

$.post({
type: "POST",
url: "http://someurl",
data: {
    id = 12345, order_items: [{
        "product_id": "1065",
        "sku": {
            "SKU": "RHJ",
            "msg": "In Stock"
        },
        "qty": "1"
    }]
    cup = 0, 
    rec = 0
},

});

现在如何发布并获得结果?

【问题讨论】:

标签: jquery json post


【解决方案1】:

而不是 $>post 使用 $.ajax 请求,这将为您提供很好的控制权。

$.ajax(
{
    type : 'POST',
    data : $(this).serialize(), // this = $('#form_id') is form id
    url  : $(this).attr('action'),
    //dataType:'json',
    success : function(data)
    {
        $('#wrapper').html(data);
    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-11
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 2021-03-31
    相关资源
    最近更新 更多