I'm struggling to understand something that i'm sure is pretty basic. I've searched around everywhere and can't find a solution to my problem.
The most related stackoverflow question I found was this one: How do I call remote API using Phonegap for Android?
That post looked promising, but still doesn't work for me. I'm building my first PhoneGap app and trying to use the Grouped api.
I don't understand conceptually how to send and receive data from PhoneGap. I'm building everything locally, so I suppose this isn't technically PhoneGap related.
Here is my api call:
http://grouped.com/api?f=user_exists&email=ryan@ensomniac.com
Should return
{"msg": true}
But all I ever get when testing locally is "Error 200" with empty data. I feel like this guy:
http://www.youtube.com/watch?list=UU4_bwov47DseacR1-ttTdOg&feature=player_detailpage&v=GsqUZkmO-zk
I'm testing inside firefox 10.0.1 on Linux from 'localhost'. I assume running locally is as similar to PhoneGap as possible but could be wrong.
Here's the code I have now that I assume should work (but obviously doesn't):
function makeRequest() {
var request = new XMLHttpRequest();
request.open("GET", "http://www.grouped.com/api?f=user_exists&email=ryan@ensomniac.com", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
console.log(request);
}
}
}
request.send();
}
makeRequest();
What am I doing wrong?
Thanks for the help, always.