2
I am having trouble accessing a PHP page via ajax. When I am trying to access the access.log the following error:
"POST /Eglise/mobile/Mob_acao.php HTTP/1.1" 200 84 "-" "Mozilla/5.0 (Linux; Android 4.4.2; XT920 Build/3_190_2009) Applewebkit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0 Mobile Safari/537.36"
In ajax I’m doing so:
jQuery.ajax({
type: "POST",
url: w_servidor+"/MOB_Acao.php",
data: dados,
success: function( data )
{
var e = $.parseJSON(data);
console.log(e.codError == 506);
}
});
My w_server variable is var w_servidor = "http://meuip:8080/eglise/mobile";
I looked about htaccess
but it has nothing to do with what is happening. The project is mobile
, and what makes us more interesting is that in mobile
works perfectly.
This request specifically I am making a query, the page that receives the request is written like this:
<?php
include "MOB_PessoasBanco_class.php";
$acao = $_POST['acao'];
error_log($acao);
if ($acao == 'verificar') {
$actionExecute = new PessoasBanco($_POST, 'verificar');
echo $actionExecute->verificarPessoas();
}
if ($acao == 'cadastrar') {
$actionExecute = new PessoasBanco($_POST, 'cadastrar');
echo $actionExecute->cadastrarPessoa();
}
The page I call next does the search in the database as follows:
$data = $this->conexao->fetchNaoRestritivo($sql, $dataInput);
But the problem is not in this part, because when I open the IntelXDK
it works perfectly, and I even did another project to test this connection and everything worked. So the problem is in my code, or in another part of the project.
your access.log message is returning ok, what kind of data Voce is sending to the server ?
– user45474
I’m sending code, email, and password
– Renan Rodrigues
to access my database and take a test.
– Renan Rodrigues
In fact, he’s not even accessing my page.
– Renan Rodrigues
What I’m seeing Oce wants to send data from a form via post with ajax how and that Oce is recovering this data Oce is entering or consulting in database? more details of the problem
– user45474
the use of parse is used in
$.post()
, for$.ajax({ })
, you must inform the type:dataType:'json'
, and what is the structure of: data ?– Ivan Ferrer
At first I saw no problem in terms of code. What it looks like is, you’re making the request correctly, but you’re not managing to handle the return. In PHP code try to return an array or json and in the Ajax request datatype set the return data type.
– Fábio Jânio