Return data from PHP
Hey quick question. I have a basic auth form working right now. Right now it is just sending a string "success" when login is successful and "false" when it is not. When its successful I want to return the users data like first name, last name, address etc. How can I do that?
I am using the createHTTPClient() to do the authentication through a php file right now.
3 Answers
-
I use Jquery && JSON. If the login is successful, PHP will return a JSON array with all the users info, if it isn't successful, it returns a json array [false]
$.ajax({type: "GET",url: 'YOURURL',data: string,timeout: 10000,success: function(res) { yourcode });
-
This should work
loginReq.onload = function(){ var your_response = this.responseText; }
-
well what I am using is pretty easy. I dont want to bring in jquery. Does my method only return text?
loginBtn.addEventListener('click',function(e) { if (username.value != '' && password.value != '') { loginReq.open("POST","http://localhost:8888/post_auth.php"); var params = { username: username.value, password: Ti.Utils.md5HexDigest(password.value) }; loginReq.send(params); } else { alert("Username/Password are required"); } });