gpt4 book ai didi

php - jQuery POST 表单数据

转载 作者:IT王子 更新时间:2023-10-29 00:20:15 25 4
gpt4 key购买 nike

当我点击提交时,我希望将所有表单数据发布到 process.php。然后在 process.php 上,我想回显 POST 数据,最后将结果 div 中的所有内容替换为在 process.php 中完成的内容。

<script type="text/javascript">
$(document).ready(function(){
$("#myform").submit( function () {
$.ajax({
type: "POST",
dataType: "html",
cache: false,
url: "process.php",
success: function(data){
$("#results").html(data);
}
});
return false;
});

//$("#myform").submit( function () {
//$('#results').html("yay");
//}
// });
//} );
});
</script>

<form name="myform" id="myform" action="" method="POST">  
<!-- The Name form field -->
<label for="name" id="name_label">zoom</label>
<input type="text" name="zoom" id="zoom" size="30" value=""/>
<br>
</select>


<!-- The Submit button -->
<input type="submit" name="submit" value="Submit">
</form>

<!-- FORM END ---------------------------------------- -->


<!-- RESULTS START ---------------------------------------- -->
<div id="results">nooooooo<?PHP $_SESSION[''] ?><div>
<!-- <input type="image" name="mapcoords" border="0" src="mapgen.php"> ---- -->
<!-- RESULTS END ---------------------------------------- -->

最佳答案

您可以调用 $.post 传递序列化的表单数据。像这样:

<script type="text/javascript">
$(document).ready(function(){
$("#myform").submit( function () {
$.post(
'process.php',
$(this).serialize(),
function(data){
$("#results").html(data)
}
);
return false;
});
});
</script>

关于php - jQuery POST 表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5772839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com