Today, when I was working, I encountered a problem. I used $. Ajax to transfer data to the background, which can operate correctly in the background, but success did not respond, and error responded. After checking the document, I realized that after jQuery version 1.4, all the returned JSON formats must meet the requirements json.org Success can only be called back correctly in the format of, otherwise jQuery will think that it returns an error Here is an example:
JSONObject j = new JSONObject();
j.put("msg","SUCCESS");
PrintWriter out = response.getWriter();
out.write(j.toString());
This is correct. JQuery calls back success
String j = "123";
PrintWriter out = response.getWriter();
out.write(j);
This is wrong, jQuery will think it is wrong
Read More:
- [Solved] it only responds to error and does not enter success after AJAX is successfully processed
- Difference between contenttype and datatype in Ajax request of jquery
- The solution that needs alert to execute after using ajax
- Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found
- [Solved] ajax Error: Uncaught SyntaxError: Unexpected end of JSON input
- If the request parameter is formdata, use the Ajax operation
- How to Fix “HTTP 405 method not allowed” Error
- Vue Error: component has been registered but not used [Two Methods to Solve]
- How to download files by post submission under Ajax
- Newline required at end of file but not found eol-last [How to Solve]
- [Solved] ESLint error: Newline required at end of file but not found (eol-last)
- [Solved] Vue3.0 Error: The component has been registered but not used vue/no-unused-components, Close eslint
- [Solved] Uncaught Error: Provide the “history“ option when calling “createRouter()“
- [Solved] error when starting dev server:Error: The following dependencies are imported but could not be reso
- [Solved] JQuery each Method Error: $XXX is not defined
- The solution to the problem that the custom styles of UI components such as element-ui in the vue project do not take effect
- xxx is assigned a value but never used [How to Solve]
- [Solved] error ‘test‘ is assigned a value but never used no-unused-vars
- Method of adding operation button for each line of data in DataGrid of easyUI