Odd Behavior With Ajax Call: Works in Safari, Not On Device

Odd Behavior With Ajax Call: Works in Safari, Not On Device

Hi all - 

I'm working on a mobile app using PhoneGap + jQuery, and running into some odd behavior. I'm not sure if this is an issue stemming from PhoneGap, jQuery, or possibly my noob-ish code... as I'm fairly new to this all. I think it would be presumptuous of me to declare it a "jQuery bug" when my hunch is it's user error on my part. I'd appreciate a fresh set of eyes (and if this is less a jQuery issue and more of a PhoneGap one... I'd love to know that as well).

So my "app" is a single page, built with HTML/CSS. I have an Ajax call out to get some data, and I'm getting some XML back. Here's the code:

  1. $.ajax({ 
  2.                 type: "POST", 
  3.                 url: http://mydomain.com/customPage.asmx/LoginMember", 
  4.                 data: memberData, 
  5.                 contentType: "application/json; charset=utf-8", 
  6.                 dataType: "json", 
  7.                 success: function(msg) { 
  8.                         alert("This is my message: " + msg); 
  9.                 }, 
  10.                 error: authenticateFailed 
  11.         }); 
So here's the weird behavior: when I test things out on my Mac in Safari, no problems. I get data back, and my alert shows up.

However, when I build out to my iPhone... the call is successful but my alert says: "This is my message: null."

Adding another layer to things, I noticed that if I use jQuery v1.4.4 or earlier... when I test on my device I get a "null" return." But if I try using v1.5.1... neither the success or error function triggers, and the call just hangs with nothing happening one way or another.

I've posted a similar question over on the PhoneGap Google Group, but it's sometimes slow over there. I'd love to know if I'm doing something wrong with my code... or if anyone else has experienced a similar type of behavior. Namely - code works fine in a browser on a desktop, but returns null when triggered from a mobile device.

I'd greatly appreciate any advice or thoughts, as I've been sidelined all day with this particular issue. I've done a lot of digging around and found a few things on GitHub that... quite frankly, I'm not sure if I totally understand. I don't know if they pertain to my issue or if they're entirely unrelated:


I love how helpful forums are, and I definitely don't want to be a user who's lazy and simply peppers the board with a lot of questions. I've tried doing the necessary legwork, but I'm at a loss... and would love some help or additional thoughts.

Thanks!
-Felix

---------
"Sometimes, I doubt your commitment to Sparklemotion..."