send info with get request in js code example
Example: send info with get request in js
document.getElementById("form").onsubmit=function(e){
e.preventDefault();
var str=document.getElementById("val1").value;
var xhr=new XMLHttpRequest();
xhr.open("GET","new.php?val1="+str,true);
xhr.onload=function(){
console.log(this.responseText);
}
xhr.send();
}
//php file
<?php
if(isset($_GET['val1'])){
$a=$_GET['val1'];
echo $a;
}