gpt4 book ai didi

php - Jquery $.post 问题

转载 作者:行者123 更新时间:2023-11-30 17:53:41 24 4
gpt4 key购买 nike

我想将我的帖子数据发送到 login.php 页面。但问题是 $.post() 不工作。告诉我这段代码的错误。

/includes/login.page(这是一个灯箱)

<form id="forgot-username-form" method="post" >
<label id="email">Forgotten your username ?</label>
<input type="email" name="forgot_username" id="user-email" />
<input type="submit" name="forgot_username" value="Send"/>
</form>

/script/用户名.js

$(document).ready(function(){
$("#forgot-username-form").submit(function() {
var email = $("#user-email").val();
alert(email);

$.post("login.php",{email:email},function(result){
alert(result);
});

});
});

/登录.php

if(isset($_POST['email'])){
$email = $_POST['email'];
echo $email;
}

帮我找出这段代码的错误。

最佳答案

试试这个,

if(isset($_POST['email'])){
$email = $_POST['email'];
echo $email;
}

如果你想使用 $_GET 方法,那就试试吧,

脚本

$.get("login.php",{email:email},function(result){
alert(result);
});

PHP 页面 login.php

if(isset($_GET['email'])){
$email = $_GET['email'];
echo $email;
}

关于php - Jquery $.post 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18456994/

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