vendredi 31 juillet 2015

Ajax call to REST service returns status:0

Ajax call from cordova android application to the REST service, returns

{ "readyState" : 0, "responseText" : "", "statusText" : "error" }

I've added <access origin="*" /> to the config.xml

    $.ajax({        
        type: "POST",    
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(dataObject),
        url: "http://ift.tt/1KGirAu",
        success: function(result){            
            if(result.auth){ 
                window.localStorage["authentication"] = result.authCode;
                window.localStorage["authDetails"] = result.details;                                    
                $.mobile.changePage("#home");    
            }                
            else{
                navigator.notification.alert('Login failed. Try again.', function() {});                        
            }
        },
        error: function(err){
            navigator.notification.alert('Error occurred unexpectedly.' + JSON.stringify(err) , function() {});
        }    
    });

The service is running in the localhost. I'm using GenyMotion as the Emulator.

Aucun commentaire:

Enregistrer un commentaire