2

I have a feeling I'm missing something obvious, but...

All my neat jQuery functions are being forced to wait by a particularly slow-moving javascript api call from within the body of the page. I'd like to have the jQuery run first, and then the api when that's done. Is there a standard way of imposing the order?

1
  • 1
    No idea what you are talking about. Any sample code? Commented Jul 6, 2010 at 7:07

2 Answers 2

4

easy workaround, call your api within a setTimeout statement.

Example:

$(document).ready(function(){
     // beautiful jQuery code here
     setTimeout(function(){
        // terribly slow code here
     }, 100);
});

It is in general a good idea to use setTimeout on heavy code/DOM manipulation. It will avoid the browser from "freezing".

Sign up to request clarification or add additional context in comments.

Comments

1

Well if you just want the jquery before the javascript, do this:

function japi(){
   japi.dosomething();
   //Your api part here
}

$("#test").html("something");
//Lots of jquery here
japi();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.