$.ajax的beforeSend,success, complete,error例子
发布时间:2020-12-16 03:36:18 所属栏目:百科 来源:网络整理
导读:jquery ajax官方文档: http://api.jquery.com/jquery.ajax/ 常用的ajax形式: $.ajax({ url: "http://192.168.2.46:8000/account/getjson/" ,type: "post" ,dataType: "json" , // 跨域使用jsonp contentType: "application/x-www-form-urlencoded; charset
jquery ajax官方文档: http://api.jquery.com/jquery.ajax/ 常用的ajax形式: $.ajax({
url: "http://192.168.2.46:8000/account/getjson/",type: "post",dataType: "json",// 跨域使用jsonp
contentType: "application/x-www-form-urlencoded; charset=UTF-8"
data: {
"user": "admin","password": "123456"
},beforeSend: function(XMLHttpRequest) {
// do something...
return true;
},success: function(data) {
// alert(JSON.stringify(data));
// do something...
},complete: function(XMLHttpRequest,textStatus) {
// textStatus的值:success,notmodified,nocontent,error,timeout,abort,parsererror
},error: function(XMLHttpRequest,textStatus,errorThrown) {
// textStatus的值:null,parsererror
// errorThrown的值:收到http出错文本,如 Not Found 或 Internal Server Error
}
});
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |