0

I have the following Ajax call in my Cordova App which i am building in VS2015 for WIndows App and the Fuction Success Result continues to return Null.. This used to work before in the previous version of Cordova.

self.displayPicture = function () {
    self.message('Loading Image');
    self.showLoading(true);

    var server = getUploadsResource();
    var url = server + '/' + self.id();
    var Token = localStorage.getItem('token');

    $.ajax({
        type: 'GET',
        contentType: 'application/json; charset=utf-8',
        url: url,
        headers: { deviceHeaderStorage: Token }
    }).done(function (successResult) {


        self.showLoading(false);
        self.showImage(true);
        self.ithasImage(true);
        self.hasChanges(false);
        self.hasNotImage(false);
        self.previewImage(false);
        self.showDelete(true);
        self.imageSrc("data:image/jpeg;base64," + successResult.Data);
        self.currentImage(successResult.Data);

    }).fail(function (errorResult) {
        self.showLoading(false);
        var messageDialog = new Windows.UI.Popups.MessageDialog("Error");
        messageDialog.showAsync();
    });
}
P. Frank
  • 5,691
  • 6
  • 22
  • 50

1 Answers1

0

You could try using the following ajax layout instead:

$.ajax({
    type: 'GET',
    contentType: 'application/json; charset=utf-8',
    url: url,
    headers: { deviceHeaderStorage: Token },
    success: function (successResult){
        //Success Code Here
    }
    error: function(co, responseObj){
        //Error Handling here
    }
});

Furthermore, to borrow from another answer:

Deprecation Notice:

The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks will be deprecated in jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

Community
  • 1
  • 1
Filipe Teixeira
  • 3,565
  • 1
  • 25
  • 45