AJAX code to pass values by POST Method in Javascript.
function datainsert(){
var xmlhr = new XMLHttpRequest();
var url = 'gethint.php';
var fname = document.getElementById('fname').value;
var lname = document.getElementById('lname').value;
var vars = "firstname="+fname+"&lastname="+lname;
xmlhr.open("POST",url,true);
xmlhr.setRequestHeader("content-type","application/x-www-form-urlencoded");
xmlhr.send(vars);
}
var xmlhr = new XMLHttpRequest();
var url = 'gethint.php';
var fname = document.getElementById('fname').value;
var lname = document.getElementById('lname').value;
var vars = "firstname="+fname+"&lastname="+lname;
xmlhr.open("POST",url,true);
xmlhr.setRequestHeader("content-type","application/x-www-form-urlencoded");
xmlhr.send(vars);
}
Comments
Post a Comment