Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Calling a service within custom Javascript

Inside the builder it is pretty easy:
Image

About JavaScript handlers, your code here (http://snippees.com/viewSnip.php?snip...) looks correct.

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Calling a service within custom Javascript

But I need it done through a function of mine that I can call - because I need to associate the response with a particular label in a grid of labels. By using my function, I can pass an identifier so I know which label the response belongs to.

Regarding the code I showed you, this is what I get when I add it to my app:
http://screencast.com/t/amnDdw04zsa

RobertJay
Posts: 0
Joined: Fri Jun 15, 2012 1:32 pm

Calling a service within custom Javascript

UPDATE: I found the solution which is shown below for any one who needs it. Just a reminder: my need for wrapping service execution in a custom function was to be able to pass a value which I could use in the success event to identify the action I should take with the response. I needed this because my service was being called repeatedly as part of a loop through another service call's response. Works perfectly for me.

function bobService(v,v2){

////////
get_top10_addresses.execute({
success: function( e ) {
//Success handler here
alert('success with latlon ' + v + ' which is iteration number ' + v2);
},
error: function( e ) {
//Error handler here
},
complete: function( e ) {
//Complete handler here
},
});
////////
}

Return to “Issues”