Search code examples
jqueryajaxfirefoxjquery-load

Firefox does not wait to Jquery.load() function


talkbox.load('/xxforum.php?webpage_id='+webpage_id , function() {
      talkbox.append('<a href="/forum/'+webpage_id+'/1" style="margin-left:40%">Go To Forum</a>');
}); 

  talkbox.removeClass("invisible").addClass("visible");

I have above code. After I load xxforum.php I append a <a> tag to end. After that I make talkbox visible. However in Firefox it does not wait to append the <a> tag. It directly shows the box and then appends the <a> tag. Which is not right because my function inside the $.load() function.In google chrome everything works as I want. Anybody encountered something like this before?


Solution

  • Problem is load is async move it inside:

    talkbox.load('/xxforum.php?webpage_id='+webpage_id , function() {
          talkbox.append('<a href="/forum/'+webpage_id+'/1" style="margin-left:40%">Go To Forum</a>');
      talkbox.removeClass("invisible").addClass("visible");
    });