继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

JQuery之$.ajaxPOST数据

android也疯狂
关注TA
已关注
手记 279
粉丝 39
获赞 243

         

    function postSimpleData() {        $.ajax({            type: "POST",            url: "/Service/SimpleData",            contentType: "application/json", //必须有            dataType: "json", //表示返回值类型,不必须            data: JSON.stringify({ 'foo': 'foovalue', 'bar': 'barvalue' }),  //相当于 //data: "{'str1':'foovalue', 'str2':'barvalue'}",            success: function (jsonResult) {                alert(jsonResult);            }        });    }

表单序列化:
    $.ajax({
        url:options.url,
        type:"POST",
        data:$("#Form1").serialize(),
        success: function(data) {
            if(options.success!=undefined)
            {
                options.success.call(this,data);
            }
        },
        error:function(){
            if(options.error!=undefined)
            {
                options.error.call(this,data);
            }
        }
    });


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP