The solution to the problem of Ajax in jquery under IE

Source: Internet
Author: User

Use jquery to send AJAX requests, which are normal under Google's browser, but fail under IE, and the first code is this:

The code is as follows Copy Code
<script type= "Text/javascript" >
$ (function () {
$ ("#fen_a a"). Live ("Click", Function (event) {
url=$ (This). attr ("href");
alert (URL);
$.ajax ({
Url:url,
Type: "Post",
DataType: "HTML",
timeout:1000,
Error:function () {
Alert ("Ajax fetch failed!") ");
},
Success:function (Result) {
$ ("#dapei_fenye"). Empty (). Append ($ (Result)-Find ("#dapei_fenye"). html ());
},
});
Event.preventdefault ();
});
})
</script>

This code is measured in Google Browser normal, under IE is not valid, if the Ajax paragraph removed, ie can see the contents of alert, Ajax Plus to go, even the contents of alert does not show. So OK is Ajax there is a problem here.

After several debugging, finally adjusted. Adjusted the error, and success the position of the two callback functions, the last callback function of the last "," comma removed, OK.

It seems that jquery's syntax is very strict under IE. The final code is as follows:

The code is as follows Copy Code
<script type= "Text/javascript" >
$ (function () {
$ ("#fen_a a"). Live ("Click", Function (event) {
url=$ (This). attr ("href");
$.ajax ({
Url:url,
Type: "Post",
DataType: "HTML",
timeout:1000,
Success:function (Result) {
$ ("#dapei_fenye"). Empty (). Append ($ (Result)-Find ("#dapei_fenye"). html ());
},
Error:function () {
Alert ("Ajax Fetch data failed!") ");
}
});
Event.preventdefault ();
});
})
</script>

IE real people have a headache ah!!

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.