首页 > Web开发 > 详细

JQuery之$.ajaxPOST数据

时间:2015-06-05 23:01:01      阅读:384      评论:0      收藏:0      [点我收藏+]
    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);
            }
        }
    });   


本文出自 “翱翔软件” 博客,请务必保留此出处http://wsoft.blog.51cto.com/2424525/1658926

JQuery之$.ajaxPOST数据

原文:http://wsoft.blog.51cto.com/2424525/1658926

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!