The JSON data format problem of the callback has caused the callback function to be unable to be executed; the solution to the jQuery Ajax Post callback function not being executed: use double quotes for JSON data, use escape characters to escape String, the code is [ {\"hello\":\"world\"}].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, DELL G3 computer. This method is suitable for all brands of computers.
Recommended: jquery video tutorial
##Solution to jQuery Ajax Post callback function not executing:
1. Front-end code$.post('${pageContext.request.contextPath}/user_deleteUser',{uid:row.uid},function(result){ if (result.errorMsg){ $.messager.show({ title: 'Error', msg: result.errorMsg }); } else { $('#dg').datagrid('reload'); } },'json');
public String deleteUser() { int count = userDao.deleteUser(model.getUid()); try { PrintWriter writer = response.getWriter(); if(count<=0) writer.write("{'errorMsg':'删除失败'}"); else writer.write("{'success':'删除成功'}"); } catch (IOException e) { e.printStackTrace(); } return null; }
我的:{'hello':'world'} 标准:{"hello":"world"}
{\"hello\":\"world\"}
Related free learning recommendations: js video tutorial
The above is the detailed content of What should I do if the jQuery Ajax Post callback function does not execute?. For more information, please follow other related articles on the PHP Chinese website!