Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9267417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:32:42+00:00 2026-06-18T14:32:42+00:00

I am wondering why in my example #1 the alerts fire in the proper

  • 0

I am wondering why in my example #1 the alerts fire in the proper order 1, 2 but in example #2 where I add an ajax call does the firing order then become 2,1. Also could anyone suggest how with using an ajax call could I achieve the desired firing order of 1, 2… I am stumped.

Example #1

uploader.bind('BeforeUpload', function (up, file, policy, sinature) {
    //alert('1');

    test();
    function test() {
        alert('1');
    }
});

uploader.bind('UploadFile', function (up, file, policy, signature) {
    test2();
    function test2() {
        alert('2');
    }
});

Example #2

uploader.bind('BeforeUpload', function (up, file, policy, sinature) {
    //alert('1');

    test();
    function test() {
        data = { alc: 'private', bucket: 'PhotojimaDev', file: file.name, key: path };
        $.ajax({
            url: sf.getServiceRoot('photojima') + "Upload/getPolicy",
            type: 'POST',
            data: data,
            beforeSend: sf.setModuleHeaders
        }).done(function (response, status) {
            if (status == "success") {
                policy = response.policy;
                signature = response.signature;
                alert('1');
            }
        }).fail(function (xhr, result, status) {
            alert("Uh-oh, something broke: " + status);
        });
    }
});

uploader.bind('UploadFile', function (up, file, policy, signature) {
    test2();
    function test2() {
        alert('2');
    }
}); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:32:44+00:00Added an answer on June 18, 2026 at 2:32 pm

    The ajax in BeforeUpload creates a non-blocking background worker that obviously doesn’t finish until after UploadFile

    If you need BeforeUpload to finish first, then you will have to tell $.ajax to not run asynchronously by adding async = false

    function test() {
        data = { alc: 'private', bucket: 'PhotojimaDev', file: file.name, key: path };
        $.ajax({
            async: false,
            url: sf.getServiceRoot('photojima') + "Upload/getPolicy",
            type: 'POST',
            data: data,
            beforeSend: sf.setModuleHeaders
        }).done(function (response, status) {
            if (status == "success") {
                policy = response.policy;
                signature = response.signature;
                alert('1');
            }
        }).fail(function (xhr, result, status) {
            alert("Uh-oh, something broke: " + status);
        });
    }
    

    Search for async in manual: http://api.jquery.com/jQuery.ajax/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering when you have for example: var dir = new DirectoryInfo(@C:\Temp);
I was wondering if anyone can post an example of how to get a
I'm wondering if there is a good example of how to edit ASP.NET Profile
I am wondering why in the following example the top and bottom padding has
I was wondering if somebody could show me an example of how to use
I was wondering if anyone could give me an example or point me to
I was wondering how I can realize with jQuery the simple example in the
I was wondering if it's possible to determine what kind of iPhone (for example)
Just wondering about the performance impact of copying very large php variables. For example
I am wondering about the use of == when comparing two generators For example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.