Вы можете отправить форму с Ajax. В чистом javascript вы можете использовать объект XMLHttpRequest.
Вот пример простого ajax.php
файла:
<?php
if (isset($_POST['ok'])) {
// send some response here
var_export($_POST);
exit;
}
?>
<!DOCTYPE html>
<html><head>
<script type="text/javascript">
function ajax() {
var form = document.forms['form1'];
var queryString = 'test=' + form['test'].value + '&ok=' + form['ok'].value;
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) { // Mozilla/Chrome/Opera/Safari/IE9+
self.xmlHttpReq = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE6-8
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', 'ajax.php', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
document.getElementById("result").innerHTML = self.xmlHttpReq.responseText;
}
}
self.xmlHttpReq.send(queryString); // send http request
return false; // disable submitting the form below and thus reloading the page
}
</script>
</head>
<body>
<form id="form1" action="" method="post" onsubmit="return ajax();">
<input type="text" name="test" value="test data" />
<input type="submit" name="ok" value="OK" />
</form>
<div id="result" style="background:#faa;"></div>
</body>
</html>
I - [а] (http://stackoverflow.com/questions/18484421/how-get-unix-timestamp-from-given-date -and-time-in-php # comment27172474_18484421) - настоятельно рекомендуем [полностью прочитать наш совет по поиску снова] (http://stackoverflow.com/questions/ask-advice) (включая все ссылки, приведенные там). – hakre