Page 1 of 2
Search for a username
Posted: Sun May 05, 2013 1:54 pm
by Michael Pierce5821971
In my game I am developing I have a popup that allows you to search for your friends username to start a game. I created a service to search for the username entered in the text input box and am using the "where" parameter for the query. I am also using Javascript on the "where" parameter to return the text inputted in the text box. The problem is no matter what name I put in the search box the service is returning a "Success" and creating a new game in the game collection of the database. I have and "Error" setup on the search service to alert that the username doesn't exist, but it always returns a success and creates a new game.
Search for a username
Posted: Sun May 05, 2013 4:40 pm
by maxkatz
Did you test the service before using it on a page and it works correctly?
Search for a username
Posted: Sun May 05, 2013 4:40 pm
by maxkatz
Also, please use browser dev. tools to see what request is being sent and what is being returned from the server.
Search for a username
Posted: Sun May 05, 2013 7:54 pm
by Michael Pierce5821971
Ok. Yes I tested it and it functioned perfectly and that's what I used to build the response from the server for my mapping. I'll try the dev tools but its weird.
Search for a username
Posted: Sun May 05, 2013 11:53 pm
by Michael Pierce5821971
This still isn't working and I really cannot figure it out. No matter what I put in the text box it is still invoking the create game service which is only supposed to be invoked if the search returns success. I checked the dev tools and it shows it is not returning a response at all but is still invoking the create game service which is only supposed to be invoked on the success of the query.
Search for a username
Posted: Mon May 06, 2013 12:15 am
by maxkatz
Do you invoke the second service on first service's success event? The service might not be returning any data but it is still a success (no error has occurred). Check the request (first service) to make sure it's correct.
Search for a username
Posted: Mon May 06, 2013 12:19 am
by Michael Pierce5821971
Yes the second service is invoked on the first service' success event. I'm not sure what to check for in the first service. Would there be a way to run a JavaScript that checks for a response and then invoke the second service?
Search for a username
Posted: Mon May 06, 2013 12:24 am
by Michael Pierce5821971
That is exactly what is happening. It returns a success but the response is blank. I'm not sure what to do now. I only want the second service to be invoked if the username that is searched for actually exists.
Search for a username
Posted: Mon May 06, 2013 12:25 am
by maxkatz
Check if the response is empty.. if yes, don't invoke the service.
Search for a username
Posted: Mon May 06, 2013 12:35 am
by Michael Pierce5821971
What would the javascript be to check a response?