Created
February 23, 2017 18:35
-
-
Save almsx/89d7125c58ff9cc2117da210eadf6fb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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