Mobile application with error

2

I'm developing an application using Apache Cordova + JQuery mobile. At some point I'm doing the following:

var nome = $("#txtNome").val();
var sobrenome = $("#txtSobrenome").val();
var sexo = $("#selectSexo").val();
var email = $("#txtEmail").val();
var login = $("#txtLogin").val();
var senha = $("#txtSenha").val(); 
$.ajax({  
headers: {
  'Accept': 'application/json',
  'Content-Type': 'application/json' 
},
url: mainURL + usuarioURL + '/inserir',
type: 'post',
dataType: 'json',
success: function(resp){
  $.mobile.loading('hide');
  alert(resp.status);
},
error: function(e){
  alert('Error occured: ' + e);
},
beforeSend: function(){
  $.mobile.loading('show');
},

data: JSON.stringify({
  nome: nome,
  sobrenome: sobrenome,
  sexo: sexo,
  email: email,
  login: login,
  senha: senha
})
});

In the browser this works perfectly, but when I do the same on the mobile phone, an error occurs and the following message appears: Error Occurred: [object Object]

Does anyone know why? Thank you. The logs are shown below:

    /www/gu.js: Line 55 : readyState: 0
    getResponseHeader: function ( key ) {
    var match;
    if ( state === 2 ) {
    if ( !responseHeaders ) {
    responseHeaders = {};
    while ( (match = rheaders.exec( responseHeadersString )) ) {
    responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
    }
    }
    match = responseHeaders[ key.toLowerCase() ];
    }
    return match == null ? null : match;
    }
    getAllResponseHeaders: function () {
    return state === 2 ? responseHeadersString : null;
    }
    setRequestHeader: function ( name, value ) {
    var lname = name.toLowerCase();
    if ( !state ) {
    name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
    requestHeaders[ name ] = value;
    }
    return this;
    }
    overrideMimeType: function ( type ) {
    if ( !state ) {
    s.mimeType = type;
    }
    return this;
    }
    statusCode: function ( map ) {
    var code;
    if ( map ) {
    if ( state < 2 ) {
    for ( code in map ) {
    // Lazy-add the new callback in a way that preserves old ones
    statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
    }
    } else {
    // Execute the appropriate callbacks
    jqXHR.always( map[ jqXHR.status ] );
    }
    }
    return this;
    }
    abort: function ( statusText ) {
    var finalText = statusText || strAbort;
    if ( transport ) {
    transport.abort( finalText );
    }
    done( 0, finalText );
    return this;
    }
    state: function () {
    return state;
    }
    always: function () {
    deferred.done( arguments ).fail( arguments );
    return this;
    }
    then: function ( /* fnDone, fnFail, fnProgress */ ) {
    var fns = arguments;
    return jQuery.Deferred(function( newDefer ) {
    jQuery.each( tuples, function( i, tuple ) {
    var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
    // deferred[ done | fail | progress ] for forwarding actions to newDefer
    deferred[ tuple[1] ](function() {
    var returned = fn && fn.apply( this, arguments );
    if ( returned && jQuery.isFunction( returned.promise ) ) {
    returned.promise()
    .done( newDefer.resolve )
    .fail( newDefer.reject )
    .progress( newDefer.notify );
    } else {
    newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
    }
    });
    });
    fns = null;
    }).promise();
    }
    promise: function ( obj ) {
    return obj != null ? jQuery.extend( obj, promise ) : promise;
    }
    pipe: function ( /* fnDone, fnFail, fnProgress */ ) {
    var fns = arguments;
    return jQuery.Deferred(function( newDefer ) {
    jQuery.each( tuples, function( i, tuple ) {
    var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
    // deferred[ done | fail | progress ] for forwarding actions to newDefer
    deferred[ tuple[1] ](function() {
    var returned = fn && fn.apply( this, arguments );
    if ( returned && jQuery.isFunction( returned.promise ) ) {
    returned.promise()
    .done( newDefer.resolve )
    .fail( newDefer.reject )
    .progress( newDefer.notify );
    } else {
    newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
    }
    });
    });
    fns = null;
    }).promise();
    }
    done: function () {
    if ( list ) {
    // First, we save the current length
    var start = list.length;
    (function add( args ) {
    jQuery.each( args, function( _, arg ) {
    var type = jQuery.type( arg );
    if ( type === "function" ) {
    if ( !options.unique || !self.has( arg ) ) {
    list.push( arg );
    }
    } else if ( arg && arg.length && type !== "string" ) {
    // Inspect recursively
    add( arg );
    }
    });
    })( arguments );
    // Do we need to add the callbacks to the
    // current firing batch?
    if ( firing ) {
    firingLength =
04-28 19:24:58.367  21790-21790/com.greeningu I/chromium﹕ [INFO:CONSOLE(55)] "readyState: 0
    getResponseHeader: function ( key ) {
    var match;
    if ( state === 2 ) {
    if ( !responseHeaders ) {
    responseHeaders = {};
    while ( (match = rheaders.exec( responseHeadersString )) ) {
    responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
    }
    }
    match = responseHeaders[ key.toLowerCase() ];
    }
    return match == null ? null : match;
    }
    getAllResponseHeaders: function () {
    return state === 2 ? responseHeadersString : null;
    }
    setRequestHeader: function ( name, value ) {
    var lname = name.toLowerCase();
    if ( !state ) {
    name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
    requestHeaders[ name ] = value;
    }
    return this;
    }
    overrideMimeType: function ( type ) {
    if ( !state ) {
    s.mimeType = type;
    }
    return this;
    }
    statusCode: function ( map ) {
    var code;
    if ( map ) {
    if ( state < 2 ) {
    for ( code in map ) {
    // Lazy-add the new callback in a way that preserves old ones
    statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
    }
    } else {
    // Execute the appropriate callbacks
    jqXHR.always( map[ jqXHR.status ] );
    }
    }
    return this;
    }
    abort: function ( statusText ) {
    var finalText = statusText || strAbort;
    if ( transport ) {
    transport.abort( finalText );
    }
    done( 0, finalText );
    return this;
    }
    state: function () {
    return state;
    }
    always: function () {
    deferred.done( arguments ).fail( arguments );
    return this;
    }
    then: function ( /* fnDone, fnFail, fnProgress */ ) {
    var fns = arguments;
    return jQuery.Deferred(function( newDefer ) {
    jQuery.each( tuples, function( i, tuple ) {
    var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
    // deferred[ done | fail | progress ] for forwarding actions to newDefer
    deferred[ tuple[1] ](function() {
    var returned = fn && fn.apply( this, arguments );
    if ( returned && jQuery.isFunction( returned.promise ) ) {
    returned.promise()
    .done( newDefer.resolve )
    .fail( newDefer.reject )
    .progress( newDefer.notify );
    } else {
    newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
    }
    });
    });
    fns = null;
    }).promise();
    }
    promise: function ( obj ) {
    return obj != null ? jQuery.extend( obj, promise ) : promise;
    }
    pipe: function ( /* fnDone, fnFail, fnProgress */ ) {
    var fns = arguments;
    return jQuery.Deferred(function( newDefer ) {
    jQuery.each( tuples, function( i, tuple ) {
    var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
    // deferred[ done | fail | progress ] for forwarding actions to newDefer
    deferred[ tuple[1] ](function() {
    var returned = fn && fn.apply( this, arguments );
    if ( returned && jQuery.isFunction( returned.promise ) ) {
    returned.promise()
    .done( newDefer.resolve )
    .fail( newDefer.reject )
    .progress( newDefer.notify );
    } else {
    newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
    }
    });
    });
    fns = null;
    }).promise();
    }
    done: function () {
    if ( list ) {
    // First, we save the current length
    var start = list.length;
    (function add( args ) {
    jQuery.each( args, function( _, arg ) {
    var type = jQuery.type( arg );
    if ( type === "function" ) {
    if ( !options.unique || !self.has( arg ) ) {
    list.push( arg );
    }
    } else if ( arg && arg.length && type !== "string" ) {
    // Inspect recursively
    add( arg );
    }
    });
    })( arguments );
    // Do we need to add the callbacks to the
    // current firing batch?
    if ( firing ) {
    firingLength = list.length;
    // With
    
asked by anonymous 26.04.2015 / 22:54

1 answer

0

Here, in date, you do not need to convert json to string.

data: { nome: nome, sobrenome: sobrenome, sexo: sexo, email: email, login: login, senha: senha }

At the most, I see no error

    
26.04.2015 / 23:00