Why jQuery ajax is not called in ie

Source: Internet
Author: User

Today, we found that jquery 1.7.2 does not call the $. get () method in ie8.

1. After debugging, I finally found that I checked ie and opened $. get (). Will be called, and the second call will not work again. So I inferred that it was an ie cache problem. After clearing the ie cache, it was enough. However, the customer cannot know how to clear the cache. So you have to find a solution on your own.

I found that all my friends on the Internet gave me a method that was included in jquery:

$. AjaxSetup ({cache: false });

In addition, it is analyzed whether ie sends requests based on whether the requested url is the same. For the same request, ie only sends an http request once, so the same request is sent multiple times, however, ie is not actually sent.

With this reason: you can add a timestamp after the url.

$. Get (
"ImgsUpload ",
{ImgsPath: path, timeStamp: new Date (). getTime ()},
Function (data ){

}
);

2. The following problems are my personal problems, but the request can be sent to the background, executed, and returned. However, the ajax callback method cannot be executed.

But it is normal in other browsers. Analyze the returned data and find a mess. That is, the returned data type is incorrect. I return json, but I want to return all data in the string format. Therefore, I have the following code on the server side:
Response. setContentType ("text/plain; charset = UTF-8 ");
Ff, chrome is normal, but ie can only recognize it as text and cannot parse it into json. All callback methods without ajax are called.

After testing, we found that you do not need to set the message header. Of course, you can also set it, but it is not text/plain,:

Response. setContentType ("application/json; charset = UTF-8 ");

The above problems should be very simple, but good friends don't even know, and the problem is difficult to find out when it is integrated. I would like to take notes here.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.