Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of error returning error and always returning error in JQuery ajax

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you how to solve the problem that error returns errors and always returns error in JQuery ajax. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Enter Baidu to search for this question and find that someone has said so.

The async of Ajax in Jquery defaults to true (asynchronous request). If you want one Ajax to execute and then execute another Ajax, you need to async=false it.

I dealt with it in ajax at that time.

Async: false, it turns out that the data returned with normal submission is normal without errors.

The code is as follows

$.ajax ({type: "POST", async: false,url:urllink, data:data,dataType: "html", success:function (msg) {alert (data)}, error: function (XMLHttpRequest, textStatus, errorThrown) {alert (XMLHttpRequest.status); alert (XMLHttpRequest.readyState); alert (textStatus);},})

One last point to add:

Sending error may be caused by the following two, or other program problems, which need us to be careful.

1. Data: "{}". If data is empty, you must pass "{}". Otherwise, the returned file is in xml format. And prompt parsererror.

The answer that jQuery ajax always returns error is as follows:

I encountered a problem when I used ajax to delete asynchronously today. Ajax can request action and the execution method is successful. But always returns the error method. I've been struggling for a long time. I have consulted a lot of information at the most. It's basically all sorts of attempts. I want to change the Ext.

It is found that some methods in action start with get. If you have carefully printed the return of ajax, you will surely find that when ajax returns, it will get all the methods in action that start with get, including the methods in action. After getting it, it is different from other get methods. You know! At this time, ajax will report 500 mistakes. Ajax will enter the error method when the state reaches 300.

The way to modify it is: simply change the method in action that begins with get to something else, such as

Public String getNetBut () {bdiList=googleFlexDAO.getBuildingIpsById (araid.trim ()); return SUCCESS;}

Modified to:

Public String findNetBut () {bdiList=googleFlexDAO.getBuildingIpsById (araid.trim ()); return SUCCESS;}

This is OK! This mistake is generally difficult to find, but you can still find it carefully.

The above content is how to solve the problem that error returns errors and always returns error in JQuery ajax. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report