$_post Variable Doesn't Work In Php Titanium
I'm trying to pass data between a JS file and a PHP file, but the variable $_POST in PHP doesn´t work and for that i can´t evolve in the app! JS code: var params = String(input.v
Solution 1:
At a guess, your JavaScript is sending data via GET:
xhr.open('GET','http://10.0.2.2/jobfinder/teste_demo_grafica/Resources/teste.php');
but your PHP is looking for POST. Change the POST to GET and it may work. Or vice versa
Solution 2:
I have the solution now! If we see this part of code:
var params = String(input.value);
** var xhr = Titanium.Network.createHTTPClient();
xhr.open('GET','http://10.0.2.2/jobfinder/teste_demo_grafica/Resources/teste.php');
xhr.send(params);
xhr.onload = function(){**
var response = this.responseText;
alert(response);
if (response != null)
{
alert("voltou ao js e funca");
}
else
{
alert("-.-");
}
};
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.onerror = function(e){alert('Transmission error: ' + e.error);};
});
the codw between ** is the problem... so i do like this:
var url = "http://10.0.2.2/jobfinder/tessssssste/Resources/teste.php";//bug do titanium resolvido var params = "?params=" + input.value;
var encodedURI = encodeURI(url + params);
var xhr = Titanium.Network.createHTTPClient();
xhr.open("GET", encodedURI);
xhr.send();
xhr.onload = function(){
and now it works TY EVERYBODY!!!!
Post a Comment for "$_post Variable Doesn't Work In Php Titanium"