The solution of calling$. Ajax successfully but the success method does not respond

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 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();
PrintWriter out = response.getWriter();

This is correct. JQuery calls back success

String j = "123";
PrintWriter out = response.getWriter();

This is wrong, jQuery will think it is wrong


Read More: