Answers for "send info with get request in js"

0

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;
}
Posted by: Guest on January-28-2021

Code answers related to "send info with get request in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language