Scene Restore: Bind a Click event to the a tag to trigger the AJAX request, in IE6, the request is often interrupted and all is normal in IE6.
<a href= "javascript:;" id= "btn" >click me</a> <script type=
"Text/javascript" src= "Jquery.js" > </script>
<script type= "Text/javascript" >
var url = "http://api.flickr.com/services/"
feeds/photos_public.gne?tags=car& "
tagmode=any&format=json&jsoncallback=?";
$ ("#btn"). Click (function () {
$.getjson (URL, function (data) {
alert (data);})
;
</script>
In IE6 use Fiddler2 monitoring request, often appear "aborted", toss for a long time, quite strange. Later, the a label was replaced with a button, the request was normal, and the last reminder may be that the default event for a label interrupted the request. However, in the HTML code, the href of a label has been set to "javascript:;", which is usually the way to block the default event (page jump). The Click event of a label executes before the href jump is executed, and if HREF is a JavaScript statement, it executes at this time. IE6 interrupts the AJAX request triggered by the click when it executes the JavaScript statement for href. Use href= "javascript:;" To prevent the default event, moving the action that prevents the default event to the Click event resolves the problem so that the JavaScript statement in HREF is not executed.
$ ("#btn"). Click (function (e) {
$.getjson (URL, function (data) {
alert (data);
E.preventdefault ();
});
Note:e.preventdefault (); The function of this sentence is to prevent the default events in JS.
The above is the entire content of this article, I hope to give you a reference, but also hope that we support the cloud habitat community.