I think this might be a security thing, but was hoping someone with more experience might be able to shed some light on this behavior I'm encountering.
Working on an iPhone app using PhoneGap (basically an HTML page with CSS/JS). I'm making a call to a webservice, and I have a little alert set up to notify me when the call succeeds. Like so:
$.ajax({ type: "POST", url:http://mydomain.com/customPage.asmx/LoginMember", data: memberData, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert("This is my message: " + msg); }, error: authenticateFailed });
When I test this code on my desktop (Mac, Safari)... it works like a peach. No problems, the function fires, and I see the expected data.
However, when I take the same code and build it onto my device (iPhone, PhoneGap)... the call still succeeds, but I'm unable to see any data. I get "This is my message: null" instead.
My best guess is this is some kind of security thing (since it works fine on my desktop, but not on my iPhone). But I'm unable to find any good mentions of this problem elsewhere. Tried posting to the PhoneGap Google Group and the jQuery forums, and trying to isolate the cause of the problem. But so far no love.
I'm fairly certain my code is ok, but just stumped as to why it's not working when it's moved onto my device. Any insights/thoughts very much appreciated!
The answer to this is that I'm an idiot. I was testing against a site that wasn't public, whose IP address I had in my machine's hosts file. That explains a bit of why I was seeing inconsistent stuff.
Changed the URL, and I'm now seeing data on my device. This is the coding equivalent of me trying to get into my house with my key... and then realizing I've been standing in front of the wrong freaking house.
Really embarrassing. But at least I have my data now.
Originally posted by: Portnoy I was testing against a site that wasn't public, whose IP address I had in my machine's hosts file. That explains a bit of why I was seeing inconsistent stuff.
man I hate it when that kind of thing happens, well done on sorting it 