Michael Pierce5821971
Posts: 0
Joined: Fri May 03, 2013 11:29 pm

Search for a username

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Search for a username

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

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

Michael Pierce5821971
Posts: 0
Joined: Fri May 03, 2013 11:29 pm

Search for a username

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Search for a username

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

Michael Pierce5821971
Posts: 0
Joined: Fri May 03, 2013 11:29 pm

Search for a username

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Search for a username

On service's complete event you can run this:

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

Michael Pierce5821971
Posts: 0
Joined: Fri May 03, 2013 11:29 pm

Search for a username

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.

Return to “Issues”