Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11880 closed bug (invalid)

jQuery AJAX call fails silently

Reported by: will@… Owned by: will@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

For some reason, the jQuery ajax call below fails silently on one of my test Android devices.

I'll see the call hit Apache, but it drops two of my parameters.

Android.logToConsole is a function I made in the Android App to simply print out strings. It works in all places I use it elsewhere in my application.

      Android.logToConsole('started');
      try {
        Android.logToConsole('0: ' + sessionId);
        Android.logToConsole('1: ' + savedSearchUrl);
        Android.logToConsole('2: ' + description);
        jQuery.ajax({
          dataType: 'jsonp',
          type: 'GET',
          url: appRootConsumerAccountServices + 'addSavedSearch',
          data: {
            sessionId: sessionId,
            savedSearchUrl: savedSearchUrl,
            description: description
          },
          success: function() {
            Android.logToConsole('success');
          },
          complete: function() {
            Android.logToConsole('complete');
          },
          error: function() {
            Android.logToConsole('error');
          }
        });
      } catch (error) {
        Android.logToConsole('exception: ' + error);
      }
      Android.logToConsole('finished');

This is my logging output in Android. You can see the data is there, and no exceptions are thrown, but none of my callbacks ever fire.

06-08 08:51:22.799: I/System.out(11591): started
06-08 08:51:22.799: I/System.out(11591): 0: 081375d098b5a5bca4b2aa69699e9909
06-08 08:51:22.819: I/System.out(11591): 1: latitude=41.877243&_returnParties=false&sort=distance+asc&view=list&resultSize=50&longitude=-87.634596&tab=1&radius=5.0
06-08 08:51:22.839: I/System.out(11591): 2: Chicago, IL near 321 S Franklin St. 60606
06-08 08:51:22.839: I/System.out(11591): finished

My Apache logs show the request

[08/Jun/2012:08:32:28 -0500] "GET /consumerAccountServices/addSavedSearch?callback=jsonp1339162399026&sessionId=98528cfb0c79ab84550937dfa2ac10c7 HTTP/1.1" 400

You can see here that two of my parameters were dropped, savedSearchUrl and description, and so my server returns a 400 error since some required parameters for that web service are missing.

When I use the same code on another device I get

06-08 09:07:14.530: I/System.out(3013): started
06-08 09:07:14.530: I/System.out(3013): 0: 6f59a0efacf675eac54fb1429e30b559
06-08 09:07:14.538: I/System.out(3013): 1: latitude=41.877196&_returnParties=false&sort=distance+asc&view=list&resultSize=50&longitude=-87.634422&tab=1&_returnRealtyTracListings=false&radius=5.0
06-08 09:07:14.538: I/System.out(3013): 2: Chicago, IL near 218 W Van Buren St. 60606
06-08 09:07:14.553: I/System.out(3013): finished
06-08 09:07:15.116: I/System.out(3013): success
06-08 09:07:15.116: I/System.out(3013): complete

And the request is perfect

[08/Jun/2012:09:06:57 -0500] "GET /consumerAccountServices/addSavedSearch?callback=jsonp1339164434054&sessionId=6f59a0efacf675eac54fb1429e30b559&savedSearchUrl=latitude%3D41.877196%26_returnParties%3Dfalse%26sort%3Ddistance%2Basc%26view%3Dlist%26resultSize%3D50%26longitude%3D-87.634422%26tab%3D1%26radius%3D5.0&description=Chicago%2C+IL+near+218+W+Van+Buren+St.+60606 HTTP/1.1" 200

I've tried upgrading to jQuery 1.7.1 and the issue remains.

The affected device is on Android 2.2

"Mozilla/5.0 (Linux; U; Android 2.2; en-kr; HTC Legend Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"

I've found that if I copy and paste (hard code) those two fields in the data {} section, then the ajax call works fine. I've also found that using encodeURIComponent on those two fields causes the call to work. But then the values get double encoded. Once by me, and again during the ajax call it seems.

My confusion (and reason for filing this bug report) is concerning why the AJAX function drops the parameters, but still calls the url, and never triggers any call backs or throws an exception. That feels like a bug in jQuery. Apologies if I'm missing something or doing anything wrong.

Change History (2)

comment:1 Changed 7 years ago by dmethvin

Owner: set to will@…
Status: newpending

We'll need a complete example, preferably in jsFiddle, rather than a code snippet.

comment:2 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.