mardi 4 août 2015

AJAX call not working in android emulator, works everywhere else (Cordova)

I have a cordova app that is acting weird. When I try the source on my browser (tested on both chrome and firefox), it works. Not on my Android emulator (got it from the Android SDK).

The weird part is that I have 2 calls. Only one works. Here's my structure.

var httpClient = null;

function login(..) {

  httpClient = $.ajax({
    type: 'POST',
    ...
    ...
  });

  httpClient.done(function(data) {
    ...
    ...
    secondCall();
  });

  httpClient.fail(...);

}

function secondCall() {

  if (httpClient != null) {
    httpClient.abort();
  }

  httpClient = $.ajax({
    type: 'GET',
    ...
    ...
  });

  httpClient.done(...);

  httpClient.fail(...);

}

The POST works. I added a console.log to test what is being fired. The first call works as it should. It called the secondCall() function, and that AJAX call fails. Is it to do with the Emulator not accepting GET requests?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire