javascript - Ajax page load in div halts browser even if it is async? -


i trying async page open inside div $.ajax still having 3sec delay after clicking link , time page jammed. happens @ least chrome , sasfari. going wrong way..?

$.ajaxsetup({     async: true }); $(document).ready(function() {     $("#button").click(function(evt) {         $('#change').html('<p><img src="ajax-loader.gif" width="15" height="15" /></p>');         $.ajax({             url: "reg.php",             cache: false         }).done(function( html ) {             $("#change").html(html);         });     }); }); 

no, asynchronous ajax requests don't hold browser. problem elsewhere, in code haven't shown. code you've shown correctly async request.

speculating on possible issues can't see:

  1. if link has href, you're not cancelling default action, loading page. can prevent default calling evt.preventdefault() within click handler, or doing return false; @ end of (which , stops propagation).

  2. if have other code elsewhere setting async: false default, perhaps ajaxsetup changing isn't getting called.


Comments