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 using ajax to implement Wechat call in jquery1.8 version

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

Share

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

Most people do not quite understand the knowledge points of this article "how to solve the problems in Wechat calls with ajax in jquery1.8 version", so the editor summarizes the following contents. The contents are detailed and the steps are clear, which can be used for reference. I hope you can get something after reading this article. Let's take a look at this article entitled "how to solve the problem of Wechat call using ajax in jquery1.8 version".

Analysis of the reason: the first thing that comes to mind is that there is a problem with the returned data type, because the jquery version above 1.4 is very strict with the json format, which needs to conform to the format {"target": true, "message": "success"}. The response object is analyzed by JSON.stringify () function, the result is consistent, and the reason is excluded.

Since ajax is going to error, I start to analyze the parameters of the error function, which are XMLHttpRequest, textStatus, and errorThrown. I found that XMLHttpRequest.status equals 0xmlhttRequest.readyState equals 0, indicating that there is a XMLHttpRequest object in the form but not initialized, and then I start to study how to initialize the XMLHttpRequest object.

Solution:

Var xmlHttpRequest;$ (function () {if (window.XMLHttpRequest) {xmlHttpRequest=new XMLHttpRequest ();} else {xmlHttpRequest=new ActiveXObject ("Microsoft.XMLHTTP");} xmlHttpRequest.open ("GET", "AjaxServlet", true);})

This solves the problem described above. Note that there will be no problem in accessing general Ajax on PC, because all browsers in PC have built-in XMLHttpRequest objects. In Wechat, this phenomenon may need to be manually built and initialized.

Ps: Android Wechat comes with a browser and IE6 browser ajax request abort error handling

A click event is bound to the page element to trigger an ajax request, which is often interrupted in Android Wechat's built-in browser and under IE6, returning the error type "abort", and everything is fine in other browsers.

Using Fiddler2 and httpWatch to monitor requests in IE6, "aborted" often appears.

Solution: add onclick='return false;' to the label

The above is about the content of this article on "how to solve the problem of using ajax to call Wechat in jquery1.8 version". I hope you all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please 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