1

I want execute below callback() method after completion of document.getElementById('btnDownload').click(); method . Now callback()executing immediatly. I want wait "Click()" process done then Execute callback(); method.

function LoadPopup() {
        //  find the popup behavior
        this._popup = $find('mdlPopup');
        // show the popup
        this._popup.show();

        // synchronously run the server side validation ...
        document.getElementById('btnDownload').click();
       callback();         
    }

 function callback() {
        this._popup = $find('mdlPopup');
        //  hide the popup
        this._popup.hide();
        alert("hi");

}

4
  • Rewrite your question. It's not clear at all what you are asking. Commented May 12, 2010 at 3:32
  • Are you saying that clicking the button activates some server-side logic, and you don't want the callback() method to execute until it's completed? Commented May 12, 2010 at 3:35
  • Put the callback inside the AJAX success? Commented May 12, 2010 at 3:36
  • Syntactic, you are right. I am want execute callback() method after completion .click() method. Commented May 12, 2010 at 3:53

2 Answers 2

1

Unless I've wildly misunderstood the question, this code will make a request to the page that the link leads to, and when the server has returned the response, executes the function:

$(document).ready(function() {
  $("#btnDownload").click(function() {
    $.ajax({
      url: $(this).attr("href"),
      complete: function(xhr, status) {
        callback();
      }
    });
    return false;
  });
});

I may have wildly misunderstood the question...

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

Comments

0

Your question is not clear. But I will give you a example.

For example, you wan to load a page by clicking on a image then after the page load is complete you want to do something you can something like this

$('#buttonid').click(function() {
    //this is the callback function of click event
    //if you want some other callback functions then you need something like this
    $("#somediv").load("page.php", function() {
       //callback function code of .load event
       alert('page loaded');
       });
 });

What you are asking is to have a callback function inside the default callback function of click event and a bit impossible from my point of view.

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.