Second variable by ajax

0

I am trying to pass a second variable by ajax to detect the language. But only the predictive text that I enter in the input passes me. I do not know where the fault may be.

These are the input of my form:

  <input type="hidden" id="idioma" name="idioma" value="<?$_GET['langu'];?>" />
  <input type="text" id="bus" name="bus" onkeyup="loadXMLDoc()"/>

And this is the ajax.js:

 function loadXMLDoc()
 {
 var xmlhttp;

 var n=document.getElementById('bus').value;


 if(n==''){
 document.getElementById("myDiv").innerHTML="";
 return;
 }

 if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }
 else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Msxml2.ServerXMLHTTP.3.0");
 xmlhttp.setOption(2, 13056);
 }
 xmlhttp.onreadystatechange=function()
 {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
 document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
 }
 }
 xmlhttp.open("POST","/proc.php",true);
 xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
 xmlhttp.send("q="+n+"&i="+$("#idioma").val());

 }

The proc.php file simply collects the variables q and i:

$q = $_POST[q];
$lang = $_POST[i];

Only the content collects me.

    
asked by JosicoLol 21.03.2018 в 16:13
source

0 answers