Page 1 of 1

Referencing the query object in JS query

Posted: Fri May 02, 2014 7:58 am
by Saul Galloway

I made a text field and a button, and on the button click event I run JS

pre
getQuestions.execute({data:{where: '{"_id":"53620e12e4b058d902d3f58b"}',
success:function(data){
alert("success! "+data);
},
error:function ( jqXHR, textStatus, errorThrown ) {
alert("error!");
}

}});
/pre

The getQuestions query is mapped to the text field

When I click the button I get pop up "Success!undefined" then pop up "error!" then the query result is placed into the text box as expected.

How do I reference the returned query object in JS?


Referencing the query object in JS query

Posted: Fri May 02, 2014 8:52 am
by Serhii Kulibaba

Hello Saul,

use:
"data":{"where": '{"id":"53620e12e4b058d902d3f58b"}'}
instead of:
data:{where: '{"id":"53620e12e4b058d902d3f58b"}'


Referencing the query object in JS query

Posted: Fri May 02, 2014 9:12 am
by Saul Galloway

Great, getting there...:-)

pre
getQuestions.execute({"data":{"where": '{"_id":"53620e12e4b058d902d3f58b"}'},
success:function(data){
// do some processing in here
// now return the processed data
return(data);
// this does not work either
// return("success handler called");
},
error:function ( jqXHR, textStatus, errorThrown ) {
alert("error!");
}
});
/pre

If I take out my success handler the data comes back and populates the bound text box as expected, and the success handler is called (if I put an alert in there, that alert gets run before before the data return), but my syntax for the return is clearly incorrrect.


Referencing the query object in JS query

Posted: Fri May 02, 2014 12:18 pm
by Serhii Kulibaba

It isn't correct using of service's events.
Look answer here: https://getsatisfaction.com/apperyio/...