ajax回调函数

1.例

$.ajax({

dataType: "json", //数据格式:JSON

url: url, //目标地址

data: {"":""},//即使无参数,也要写。 ******************

async:false,//异步执行,这个ajax执行完后才能执行其他的js

error:function(XMLHttpRequest, textStatus, errorThrown) {

alert(XMLHttpRequest.status);//返回200,url提交成功

alert(XMLHttpRequest.readyState);//返回 4,(完成)响应内容解析完成,可以在客户端调用了

**********status 和redyState 返回非200和4,则火狐浏览器调试查看。

alert(textStatus);// 如果错误,返回"timeout", "error","notmodified" 和"parsererror",我遇到的是parserror 解析json时错误,原因

没有继承json-default

},

success: function (data){

//data 是封装好的json,一个对象。data.result,result在后台java中必须get、set,才能在回调函数中调用。

if(data.result==1){ self.location="login_yzm.jsp";

//window.navigate("login_yzm.jsp"); }

}

});

******************

//data: {valimobile:valimobile,username:name,isreport:'0'},

相关推荐
敲代码的鱼哇1 小时前
发送短信/拨打电话/获取联系人能力 UTS 插件(cz-sms)
android·前端·ios·uni-app·安卓·harmonyos·鸿蒙
用户5052372099152 小时前
Android 13/14 通知权限与前台服务适配指南
android
用户5052372099152 小时前
Android 12 适配指南:SplashScreen API 与 PendingIntent 变更
android
用户5052372099152 小时前
一张表看懂 Android 8-15 所有适配要点
android
_祝你今天愉快2 小时前
Android 12 (AOSP) 添加自定义系统服务
android
程序员陆业聪4 小时前
AI编码提效实战:Skill、Rule与上下文工程
android
程序员陆业聪5 小时前
AI驱动需求梳理与Spec编写:让PRD自动变成技术方案
android
李艺为7 小时前
Android Studio使用switch匹配资源id时报需要常量表达式解决办法
android
4311媒体网8 小时前
织梦CMS点击率统计实现方法
okhttp
YaBingSec8 小时前
玄机靶场-2024ccb初赛sc05 WP
android·运维·网络·笔记·安全·ssh