jquery $.post方法不执行怎么办


本文摘自PHP中文网,作者coldplay.xixi,侵删。

jquery $.post方法不执行的解决方法:设置返回的数据为json数据,代码为【out.print(JSONObject.fromObject(result));】。

本教程操作环境:windows7系统、jquery3.2.1版本,该方法适用于所有品牌电脑。

jquery $.post方法不执行的解决方法:

关于JQuery的post回调函数不执行问题

前端的post回调函数就是不执行, 设置完断点debug还是直接跳过不执行

错误演示 :

后台代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

@RequestMapping(value = "login")

public void CheckUserAccount(@RequestParam("account")String account, HttpServletResponse response) throws IOException{

JSONObject json_account = JSONObject.fromObject(account);

int username = (Integer)json_account.get("username");

String password = json_account.getString("password");

logger.info("username = " + username + " password = " + password);

int status;

status = checkUserAccountService.IsCorrect(username, password);

Map<String, Object> result = new HashMap<String, Object>();

Map<String, String> info_json = new HashMap<String, String>();

if(status == 1){

info_json.put("status", "success");

}else if(status == 0){

info_json.put("status", "errorpassword");

}else{

info_json.put("status", "noexitaccount");

}

result.put("info", info_json);

JSONObject json_object = JSONObject.fromObject(result);

response.setContentType("text/json; charset=utf-8");

response.setHeader("Cache-Control", "no-cache");

PrintWriter out = response.getWriter();

out.print(result);

out.flush();

out.close();

logger.info("验证结果是" + ((Map<String, String>)(result.get("info"))).get("status"));

重点的一句是:

阅读剩余部分

相关阅读 >>

如何解决jQuery不兼容问题

jQuery获取url的参数乱码怎么办

jQuery load方法加载文档时的中文乱码怎么办

jQuery中on()和live()的区别是什么?

jQuery怎么去除css样式?

jQuery三大版本之间有什么区别?

使用jQuery实现网站导航抖动效果

jQuery如何清空input中的内容

jQuery如何判断元素内容是否为空

jQuery实现div显示、隐藏和文字填充

更多相关阅读请进入《jQuery》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...