0

I have the following:

var archiveFolders = function (ids) {
     var options = {// stuff}
     return $.ajax(options)
}

archiveFolders(data).then(alert("heyo"));

But "heyo" is getting displayed immediately after the call to archiveFolders, NOT after the call finishes. How to I wait to display "heyo" until I get a response from the server?

5
  • Is your AJAX call actually happening? Commented Jul 23, 2013 at 2:42
  • yes, I see a breakpoint get hit on the serverside AFTER the alert is thrown Commented Jul 23, 2013 at 2:42
  • Provide a full reproducible example. Commented Jul 23, 2013 at 2:43
  • Give me an AJAX endpoint to hit Commented Jul 23, 2013 at 2:44
  • Nevermind, I see the problem... Commented Jul 23, 2013 at 2:45

1 Answer 1

1

This problem is actually quite simple. alert("heyo") is evaluated immediately. Try this instead:

archiveFolders(data).then(function () {
  alert("heyo");
});
Sign up to request clarification or add additional context in comments.

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.