...

Hi! I’m Starx

experienced Software Developer. And this is my blog
Start Reading About me
Blog Page
May 12, 2010

execute javascript method after completing code behind method?

Question by James123

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");

}

Answer by Starx

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.

Read more
...

Please fill the form - I will response as fast as I can!