4
I will explain this my post better, I think I have not been clear on the issue.
Today, I have a page where I search for a certain term and the result is presented to me then a search AJAX Live Search
.
The page looks like this:
The code is like this, I have a field input
with the ID defined as Termo
, see:
<input type="text" class="form-control required" id="Termo" value="" onkeyup="sendRequest();" placeholder="Informe uma palavra">
The function called is like this:
// BUSCA DINÂMICA function sendRequest() { var Termo = document.getElementById('Termo').value; if (Termo.length > 2) { var url = "pBuscaRamais.php?Termo=" + Termo; ajax.open('GET', url, true); ajax.onreadystatechange = ajaxListener; ajax.send(null); } } function ajaxListener() { if (ajax.readyState == 1) { // INSERIR GIF DE CARREGAMENTO } else if (ajax.readyState == 4 && ajax.status == 200) { ramais.innerHTML = ajax.responseText; // REINICIALIZANDO A FUNÇÃO APÓS O RETORNO // DETALHES scripts.js _toggle(); } }
What I’m trying to do, search for a thermopo from another page, passing the input to the iBuscaRamais.php page, retrieve the variable, call a function and return the search on the iBuscaRamais.php page.
The page of that call is this:
The code html
of the same is so:
I am recovering the variable Term on the iBuscaRamal.php page, the recovered variable is with the typed content, the problem is how to call the function that I can do the search and return me, in this search is not a AJAX Live Search
I’m retrieving the variable and trying to pass the variable like this:
if (isset($_POST['Termo'])) { $Termo = $_POST['Termo']; echo " function loadDoc($Termo){ } " }
And the so-called function is this:
function loadDoc() { var Termo = ""; console.log(Termo); var url = "pBuscaRamais.php?Termo=" + Termo; ajax.open('GET', url, true); ajax.onreadystatechange = ajaxBuscaIndex; ajax.send(null); } function ajaxBuscaIndex() { if (ajax.readyState == 1) { // INSERIR GIF DE CARREGAMENTO } else if (ajax.readyState == 4 && ajax.status == 200) { ramais.innerHTML = ajax.responseText; // REINICIALIZANDO A FUNÇÃO APÓS O RETORNO // DETALHES scripts.js _toggle(); } }
On my console I am not presented any error message, but it does not work.
This $_POST is coming through an action?
– MagicHat
Put the whole section, where the values are being passed to the variable $Term, if you have a silly mistake is easy to see...
– MagicHat
Well let’s go in pieces, make a test there in the $_POST, and see if the variable is coming... It has not been done but... That way we will funnel the error... Give an echo where you are receiving the variable...
– MagicHat
Hello@Magichat, thanks for the tip, yes, the variable is with value.
– adventistapr
Less 1 problem, then the problem is in the function call or the function itself...let there... Appears some error ?
– MagicHat
Not missing, sorry if wrong, initialize request? var ajax = new Xmlhttprequest();
– MagicHat
Don’t put it in the post, but I am getting started @Magichat.
– adventistapr
um... boot there tmb , to follow, every detail is relevant.
– MagicHat