cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a function from one function in sapui5

0 Kudos
4,569

Hi experts ,

I developed here one oData Get call  that is working fine. But form the success function i just need to call one more function there .

So how to call the other function from the success function.

Plz correct me if i may did wrong anywhere. And send me your guidelines.

I attached my coding here .

press :function () {

  var surl = "service url here ";

     OData.request

                      ({ 

        requestUri:surl, 

                 method: "GET", 

                 headers:

                     {      

       "X-Requested-With": "XMLHttpRequest",

       "Content-Type": "application/atom+xml",

       "DataServiceVersion": "2.0",         

      "X-CSRF-Token":"Fetch"                               

                }       

              },

             function(data, response) { // onSuccess function called when everything is ok

  

       this.applySearch(); // if i call  the function like this i am getting error like this is not a function like that

   

   

    }

},

applySearh : function  () {

}

Thanks and  Regards ,

Damian .A

View Entire Topic
SergioG_TX
Active Contributor

Damian,

that is because this is out of scope... you can have

var self = this;

right before your ajax call..

then inside the success function:

self.applySearch();  // instead of this

0 Kudos

Thank you so much  i got the

answer ..

agentry_src
Active Contributor
0 Kudos

Please mark this Discussion with a Correct Answer (closes, but does not lock the Discussion) and Helpful Answer where appropriate. See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why   Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be. 

Do not use Assumed Answered as it confuses anyone looking for the specific answer.  If you dig into the Getting Started link (top right of each SCN page), you are only instructed to mark Helpful or Correct Answers to Discussion responses. 

Thanks, Mike (Moderator)

SAP Technology RIG