Page 1 of 1

How to generate javascript query of collection

Posted: Thu May 01, 2014 10:04 am
by Saul Galloway

Trying to generate a quiz app. My sample data

pre
[
{
"id":"53620e12e4b058d902d3f58b",
"question":"How was your experience today?, Very good, Good, Average, Poor, Very poor",
"createdAt":"2014-05-01 09:04:18.125",
"updatedAt":"2014-05-01 09:04:18.125"
},
{
"id":"53620e2de4b058d902d3f58c",
"question":"How do you rate your service?, Great, OK, Terrible",
"createdAt":"2014-05-01 09:04:45.164",
"updatedAt":"2014-05-01 09:04:45.164"
}
]
/pre

I think what I want is on an event like button click to run a back end query in javascript to return the first question and answer stubs, and then slot those responses into the UI elements.

Completely befuddled as to how to even make a start. A quiz example would be a great addition.


How to generate javascript query of collection

Posted: Thu May 01, 2014 10:47 am
by Nikita

Hi,

Unfortunately, we don't have a quiz example. You should use some query constraints for your purposes: http://docs.appery.io/documentation/b...


How to generate javascript query of collection

Posted: Thu May 01, 2014 4:16 pm
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?


How to generate javascript query of collection

Posted: Tue May 06, 2014 11:29 am
by Evgene Karachevtsev

Hello, Saul

You can create success and error event with appery.io visual builder not from javascript code.


How to generate javascript query of collection

Posted: Thu Aug 06, 2015 9:41 am
by ahmet7661733

What does this mean:

You can create success and error event with appery.io visual builder not from javascript code.

I have the same problem.

I want to see "data" as result of the query but I got also "undefined" as response.

data.length works, are there any other options besides the "length".

Thanks,


How to generate javascript query of collection

Posted: Thu Aug 06, 2015 1:42 pm
by ahmet7661733

Hi,
I have the same problem,

I want to know what is returned after a database query.::

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

Why Do I see ::::: data = 'unknown' ?????????????????????

and how to solve this?

How to get information in "data" ???????????


How to generate javascript query of collection

Posted: Sun Aug 09, 2015 7:15 pm
by Serhii Kulibaba

Ahmet,

Please change

'{"id":"53620e12e4b058d902d3f58b"}'
to:
{"id":"53620e12e4b058d902d3f58b"}

(remove quotes)