$.ajax({ type:'post', //String 默认为GET timeout:'2000', //Number 设置超时时间(毫秒) url:{""}, //String 发送请求的地址
async: false, //同步(默认true,异步加载)dataType:"json", //String xml、html、script、json、jsonp、jQuery、text data:{'userName':userName}, //发送给后台的请求数据 "userName":userName或者 data: {username:$("#userName").val(),password:$("#password").val()}, //提交前回调函数(发送请求前可以修改XMLHttpRequest对象的函数) beforeSend:function(XMLHttpRequest){ this; //调用本次Ajax请求时传递的options参数 }, //请求成功后处理(data可能是xmlDoc、jsonObj、html、text;textStatus (请求状态):success、error、notimodified、timeout) success:function(data,textStatus){ this; //调用本次Ajax请求时传递的options参数//window.location.href = data.getCodeUrl;/*location.reload();*/ }, //请求失败后调用(通常情况下textStatus和errorThrown只有其中一个包含信息) error: function (XMLHttpRequest,textStatus,errorThrown) { this; //调用本次Ajax请求时传递的options参数 console.log("error-----------"); }, //请求完成后处理(请求成功或失败时均调用) complete:function(XMLHttpRequest,textStatus){ this; //调用本次Ajax请求时传递的options参数 } });
Ajax详细参数介绍
最新推荐文章于 2022-05-23 11:35:48 发布