Jquery ajax ie returns an error, chrome firefox normal solution

Source: Internet
Author: User
Tags json

For web development, basically is under the Chrome,firefox development, then will consider IE compatibility problem, because IE developer tools, bad use. For the normal under Chrome,firefox and in IE bad use of the situation, but also to calm down a bit, this is the developer will inevitably encounter problems. Next, Ajax in Chrome,firefox under normal use, IE (IE8) under the abnormal 2 kinds of common situation.

1, the cache problem, Ajax submitted to a URL, the first normal, second or first content, the common solution is to add a random number after the URL, or timestamp.


2,php Header Setup Issue


Header ("content-type:text/html;   Charset=utf8 "); The header is added to the top of PHP to return the data text type

$.ajax ({
Type: "POST",
Url:url,
Data: ' domain= ' +$ (obj). attr ("Alt"),
DataType: "JSON", in//JS code, the settings return data to JSON, which conflicts with PHP above.
...........................

In this case, IE is not recognized, the request is 200, but the return data is Null,chrome Firefox normal. The simplest solution is to remove the content-type.
If this is the case, Ie,chrome,firefox will have any return value, try it yourself


Header ("Content-type:application/json; Charset=utf8 ");  //php the top of the header, returns the data JSON type  
 
 $.ajax { 
 type:" POST ", 
 url:url, 
 data: ' domain= ' +$ (obj). attr (" alt "), 
 datatype:" Text ",    //js code, set the return data to text, which conflicts with PHP above."  

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.