Cordova app can't make JSONP AJAX request - 401 error


#1

For some reason, the desktop version of my app works fine, but the mobile one does not. I’m making this call from the client:

    $.ajax(`${apiBaseUrl}/get_recent_posts`, {
      dataType: 'jsonp'
    }).done(function (data) {
      console.log('done, firing callback');
      callback(data.posts);
    }).fail(function (jqXHR, textStatus, errorThrown) {
      console.log('FAIL. dumping everything!');
      console.log(jqXHR);
      console.log(textStatus);
      console.log(errorThrown);
    }).always(function (jqXHR, textStatus, errorThrown) {
      console.log('always?');
    });

And getting this error in the Safari console:

Failed to load resource: the server responded with a status of 401 (Unauthorized

It’s interesting to note that neither done, fail, nor always fire. Why would the desktop version work but the mobile one not?


#2

I encountered the same problem that ajax called to my .NET WebAPI works on desktop, but not on iOS 10 iPhone 6 Plus.
If any one know what needs to be done please let us know.

Thank you in advanced.

Brian