Why i not get post data when use javascript submit form by not loadpage ?
First load page a.php and then press OK button
why not echo $_POST["id"]
Here is javascript code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<form id="myForm" name="myForm" action="b.php" method="post">
<input type="text" name="id" value="1111111111111111111">
<button name="element" id="element" type="submit">OK</button>
<div id="element_loading" style="display: none;">loading..................</div>
<span id="element_result"></span>
</form>
<script type="text/javascript">
$('#myForm').submit(function(e){
e.preventDefault();
$.ajax({
url: $("#myForm").attr("action"),
data: $("#myForm:input").serializeArray(),
type: 'post',
dataType: 'html',
success: function(data){
$("#element_result").html(data);
},
beforeSend: function(){
document.getElementById("element").disabled = true;
document.getElementById("element_loading").style.display="inline";
$("#element_result").hide()
},
complete: function(data){
document.getElementById("element").disabled = false;
document.getElementById("element_loading").style.display="none";
$("#element_result").show()
}
});
});
</script>
And this is php code
<?PHP echo $_POST["id"]; ?>