Saul Galloway
Posts: 0
Joined: Wed Apr 30, 2014 7:52 am

How to generate javascript query of collection

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.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

How to generate javascript query of collection

Hi,

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

Saul Galloway
Posts: 0
Joined: Wed Apr 30, 2014 7:52 am

How to generate javascript query of collection

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?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to generate javascript query of collection

Hello, Saul

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

ahmet7661733
Posts: 0
Joined: Sun Jul 26, 2015 10:50 am

How to generate javascript query of collection

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,

ahmet7661733
Posts: 0
Joined: Sun Jul 26, 2015 10:50 am

How to generate javascript query of collection

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" ???????????

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to generate javascript query of collection

Ahmet,

Please change

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

(remove quotes)

Return to “Issues”