gpt4 book ai didi

javascript - jQuery PHP 帖子

转载 作者:行者123 更新时间:2023-12-03 00:32:26 24 4
gpt4 key购买 nike

我遇到一个问题,也许很简单,但不知道如何加载 jquery_post.php 当我发送 jquery_send.php 的数据时,我继续将信息从 jquery_send.php 发送到 jquery_post.php ,我希望在发送页面 jquery_post 之后.php 加载数据

这是我在 jquery_send.php 中的内容:

<html>
<head>
<link href='http://fonts.googleapis.com/css?
family=Source+Sans+Pro|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("#btn").click(function(){
var vname = $("#name").val();
var vemail = $("#email").val();
if(vname=='' && vemail=='')
{
alert("Please fill out the form");
}
else if(vname=='' && vemail!==''){alert('Name field is required')}
else if(vemail=='' && vname!==''){alert('Email field is required')}
else{
$.post("jquery_post.php",
{
name:vname,
email:vemail
},
function(response,status){
alert("*----Received Data----*nnResponse : " + response+"nnStatus : " + status);
$("#form")[0].reset();
});
}
});
});
</script>
</head>
<body>
<div id="main">
<h2>jQuery Ajax $.post() Method</h2>
<hr>
<form id="form" method="post">
<div id="namediv"><label>Name</label>
<input type="text" name="name" id="name" placeholder="Name"/><br></div>
<div id="emaildiv"><label>Email</label>
<input type="text" name="email" id="email" placeholder="Email"/></div>
</form>
<button id="btn">Send Data</button>
</div>
</body>
</html>

在 jquery_post.php 中我有这个:

<?php
if($_POST["name"])
{
$name = $_POST["name"];
$email = $_POST["email"];
echo "Welcome ". $name ."!";
?>

最佳答案

它工作得很好,但是你的jquery_post.php

中有一个语法错误
<?php
if($_POST["name"])
{
$name = $_POST["name"];
$email = $_POST["email"];
echo "Welcome ". $name ."!";
} // you missed this
?>

它返回解析错误:语法错误,意外的文件结尾

关于javascript - jQuery PHP 帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53799029/

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