SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    {jquery}- How do i get function to execute ONLY after ajax call is complete

    i have the following
    Code:
          function getaccountcurncy2(){
                    var entity = $("#sourceacctno").val();
                    //alert(entity);
                    $.ajax({
                            type: "POST",
                            url: "getpartneraccountcurncy.php",
                            data: 	"param=" + entity,
                            success: function(html){
                                    $("#sourcactcurncy").val(html);
                            }
                    });
                }
    I need to execute the function getexchrate() ONLY after the ajax call is complete. All my previous attemps executes the function before the ajax call is completed. getexchrate() depends on the outcome of the ajax call.
    Prov. 13:20 - He that walketh with wise men shall be wise: but a
    companion of fools shall be destroyed

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jquery calls the success function when the request is done.

  3. #3
    SitePoint Evangelist Maujor's Avatar
    Join Date
    Mar 2005
    Location
    Rio de Janeiro - Brazil - South America
    Posts
    409
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the complete key with your function as value
    Code:
    function getaccountcurncy2(){
       var entity = $("#sourceacctno").val();
          //alert(entity);
          $.ajax({
            type: "POST",
            url: "getpartneraccountcurncy.php",
            data: "param=" + entity,
            success: function(html){
               $("#sourcactcurncy").val(html);
            }
            complete: function() {//your function goes here}
    });
                }
    Mauricio Samy Silva
    http://www.maujor.com/

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks !
    Prov. 13:20 - He that walketh with wise men shall be wise: but a
    companion of fools shall be destroyed


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •