- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 11:00 AM
When a user click on a button my client script will take that info and sent it to the server to do some calculation. After that what do I put in the client script to pull the result back from the server?
This is what I have so far.
HTML:
<button class="button" ng-click="c.redirect(name)">Submit</button>
Client:
c.redirect = function(name){
c.server.get({passVal:name}).then(function(r){});
}
Server:
if(input){
var find = input.passVal;
//Do stuff
returnResult = //done <---set result to returnResult
}
else{
var returnResult = {};
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 11:56 AM
Set a property in your data object to the value that you want returned and you'll then be able to access it in your then() function. Try something like this:
Client:
c.redirect = function(name){
c.server.get({
action: yourAction,
passVal: name
}).then(function(r){
c.result = c.data.returnResult;
});
}
Server:
if(input && input.action === "yourAction"){
var find = input.passVal;
//Do stuff
data.returnResult = //done <---set result to returnResult
} else {
data.returnResult = {};
}
You might not need the whole action part, but whenever using server.get I always add an action to my custom input object.
Let me know if this helps,
Dylan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 11:35 AM
You'd most likely need to store that information in a variable and then pass that back to the form, I assume that's what you want to do.
So you'd g_form.setValue('fieldnameonform', variablename);
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 11:56 AM
Set a property in your data object to the value that you want returned and you'll then be able to access it in your then() function. Try something like this:
Client:
c.redirect = function(name){
c.server.get({
action: yourAction,
passVal: name
}).then(function(r){
c.result = c.data.returnResult;
});
}
Server:
if(input && input.action === "yourAction"){
var find = input.passVal;
//Do stuff
data.returnResult = //done <---set result to returnResult
} else {
data.returnResult = {};
}
You might not need the whole action part, but whenever using server.get I always add an action to my custom input object.
Let me know if this helps,
Dylan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 12:51 PM
Thank you for the help.