Page 2 of 2

Search for a username

Posted: Mon May 06, 2013 2:46 am
by Michael Pierce5821971

How would I write this code to check for an empty response?


Search for a username

Posted: Mon May 06, 2013 3:14 am
by maxkatz

http://docs.appery.io/documentation/a...

The 'data' object has the data returned. Check out jQuery docs to see what's inside that object.


Search for a username

Posted: Mon May 06, 2013 3:41 am
by Michael Pierce5821971

I am still not figuring this out on how to validate if the response if empty.


Search for a username

Posted: Mon May 06, 2013 3:44 am
by maxkatz

If (response is empty)
invoke service
else
do something else


Search for a username

Posted: Mon May 06, 2013 3:19 pm
by Michael Pierce5821971

is (response is empty) an actual condition that can be tested or is there another way to get the response from the server? the service is called get_friend, how do I get the response so I can test if it is empty?


Search for a username

Posted: Mon May 06, 2013 4:13 pm
by maxkatz

On service's complete event you can run this:

var res = jqXHR.responseText;
if (res == "")
// do something
else
// do something else


Search for a username

Posted: Tue May 07, 2013 1:04 pm
by Michael Pierce5821971

Thanks Max! Just an FYI checking if it was blank by just doing "" didn't work. I had to check if the response text was "[]" for it to work. Evidently the square brackets are part of the text response.