jQuery, AJAX and PhoneGap (oh, my!)
I am developing my first (production) PhoneGap app. I'm using jQuery 1.10.2. According to the jQuery doc:"As of jQuery 1.8, the .ajaxComplete() method should only be attached to document."
In my prototype page, I did just that and attached the handlers to $(document).
- $(document).ajaxSend(function (data, hdr, settings) {
- // stuff
- }).ajaxComplete(function (ev, req, options) {
- // stuff
- }).ajaxError(function (err, data, status, exc) {
- // stuff
- }).ajaxSuccess(function (xhdr, data, settings) {
- // stuff
- });
This works in my browser, but not in PG. In PG, I have to attach the handlers to the $.ajax() call itself.
- $.ajax({
- url: url,
- type: "get",
- dataType: "JSONP",
- contentType: "application/json;charset=utf-8"
- }).always(function (data, hdr, more) {
- // stuff
- }).error(function (data, err, status) {
- // stuff
- }).success(function (data, status, more) {
- // stuff
- });
Is this a known issue? Is it an issue with PG?
It's not a show stopper by any means, but I really don't want to maintain 2 different methods of maintaining AJAX calls between web site and PhoneGap.
Thoughts? TIA!