ajax on hold for while - jQuery

203 Views Asked by At

I have 2 ajax call on single click, is there any way to hold one Ajax for while and get another Ajax response.

ie.

jQuery.ajaxPrefilter( function( options, originalOptions, jqXHR ) {

    try {
        if ( originalOptions.data == null || typeof ( originalOptions.data ) == 'undefined' || typeof ( originalOptions.data.action ) == 'undefined' ) {
            return true;
        }
    } catch ( e ) {
        return true;
    }

    if ( originalOptions.data.action == 'messages_send_reply' ) {
        if ( messageObj[ widget_id ] ) {

            // Secound Ajax calling from here.
            messageObj[ widget_id ].uploadFiles();

            // Secound ajax responce.
            messageObj[ widget_id ].uploader.bind( 'FileUploaded', function( up, file, res ) {
                if ( res.response ) {

                    // Bind secound ajax response with first Ajax.
                    options.data += "&secound_res=" + res.response;
                    console.log( '1' );
                }
            } );
            console.log( '2' );
        }
    }
    console.log( '3' );
} );

And my console looks like this.

2
3
1

But it shoud like

1
2
3

NOTE: I dont have access to edit from ajax call i need to play with ajaxPrefilter only.

0

There are 0 best solutions below