Skip to content

Instantly share code, notes, and snippets.

@almsx
Created February 23, 2017 18:35
Show Gist options
  • Save almsx/89d7125c58ff9cc2117da210eadf6fb2 to your computer and use it in GitHub Desktop.
Save almsx/89d7125c58ff9cc2117da210eadf6fb2 to your computer and use it in GitHub Desktop.
function LoginUsuarios(usuario, password) {
var url = 'http://www.sitio.com/Login.php';
var xhr = Titanium.Network.createHTTPClient({
onload : function(e) {
obj = this.responseText;
var nuevojson = JSON.parse(obj);
console.log(nuevojson);
if (nuevojson.mensaje == 'UserPassIncorrecto') {
alert('Usuario o Contraseña incorrecto, favor de verificar');,
} else if (nuevojson.mensaje == 'usuarioExiste') {
alert('bienvenido');
} else if (nuevojson.mensaje == 'noExiste') {
alert('El Usuario ingresado no existe');
}
},
onerror : function(e) {
obj = this.responseText;
var nuevojson = JSON.parse(obj);
$.transparenteCargando.visible = false;
var a = Titanium.UI.createAlertDialog({
title : Alloy.Globals.nombreApp,
message : nuevojson.message,
buttonNames : ['OK']
});
a.show();
},
timeout : 10000000
});
var params = {
"usuario" : 'pepito'
"password" : '123456'
};
xhr.open("POST", url);
xhr.send(params);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment