ajax demo

$.ajax({
async : true ,   //true异步,false同步
url     : '',
data    : $(this).serialize() ,
type    : 'get',
dataType : 'json' ,     //xml,html,script,json,jsonp,text
complete : function(XHR ,TS){ alert('complete');} , //完成回调函数(XHR, TS)
error    : function(XMLHttpRequest,textStatus ,errorThrown){
//          XMLHttpRequest.readyState:
//          0 - (未初始化)还没有调用send()方法
//          1 - (载入)已调用send()方法,正在发送请求
//          2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
//          3 - (交互)正在解析响应内容
//          4 - (完成)响应内容解析完成,可以在客户端调用了
//          XMLHttpRequest.status:
//          textStatus: "timeout", "error", "notmodified" 和 "parsererror"。
//          (0)null
//          (1)timeout 超时
//          (2)error
//          (3)notmodified 未修改
//          (4)parsererror 解析错误
console.log( XMLHttpRequest );
            console.log( textStatus  );
            console.log( errorThrown );
 
         },//默认值: 自动判断 (xml 或 html)。请求失败时调用此函数。有以下三个参数:XMLHttpRequest 对象、错误信息、(可选)捕获的异常对象。
success  : function( response ){ alert('success');}
      });
            $.ajax({
                type: 'POST',
                url: location.href,
                data: {
                    "id": "<%=ID%>",
                    "stime": $("#StartTime").val(),
                    "etime": $("#EndTime").val(),
                    "ywUserName": $("#lbYWUser").val(),
                    "xch": xch,
                    "action":"Save"
                },
                success: function (data) {
                    if (data.status == "1") {
                        art.dialog.alert('succeed',data.message,null);
                    } else {
                        art.dialog.alert('error',"系统错误,保存失败!",null);
                    }
                },
                complete: function (XHR, TS) {
                    $("#btnSave").attr('disabled', false);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            })


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值