I'll explain this post better, I do not think it was clear on the issue.
Today, I have a page where I search for a certain term and the result is then presented to me, a search AJAX Live Search
.
The page looks like this:
Thecodeislikethis,Ihaveafieldinput
withtheIDsettoTermo
,see:
<inputtype="text" class="form-control required" id="Termo" value="" onkeyup="sendRequest();" placeholder="Informe uma palavra">
The calling function looks 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, searching for a term from another page, passing the input to the iBuscaRamais.php page, retrieving the variable, calling a function, and returning the search on the iBuscaRamais.php page.
The page for this call is this:
Thecodehtml
ofitislikethis:
I'mretrievingtheTermvariableintheiBuscaRamais.phppage,theretrievedvariableiswiththecontenttyped,theproblemishowtocallthefunctionthatIcandothesearchandreturntome,inthatsearchitisnotaAJAXLiveSearch
I'mretrievingthevariableandtryingtopassthevariablelikethis:
if(isset($_POST['Termo'])){$Termo=$_POST['Termo'];echo" function loadDoc($Termo){ } " }
And the 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(); } }
My console does not display any error messages, but does not work.