我正在使用data()
方法记录信息
optionScope.data().stage = 'a';
where optionScope = $(this);
我想在我的 php 代码中存储这个值:
<?php
include("functions/db.php");
$format = "Online Course";
$stage = GETTING THIS DATA;
$topic = "Idea Generation";
$resources = "select * from resources where format LIKE '".$format."' and stage LIKE '%".$stage."%' ";
$run_query = mysqli_query($con, $resources);
while($row = mysqli_fetch_array($run_query)) {
$stage = $row['stage'];
echo "$stage <br>";
}
?>
更新: 数据如何发送
optionScope.data().stage = 'b';
$.ajax({
url: "functions/contact.php",
type: "post",
data: {stage: optionScope.data().stage}
});
如何检索数据
<?php
$stage = $_POST['stage'];
echo $stage;
?>
最佳答案
您可以使用AJAX方法。这是将 JS 数据传输到 PHP 脚本的唯一方法。您将在 GET 或 POST 变量中获取 Jquery 数据。 jQuery AJAX 有多种方法,您可以根据您的要求进行选择。 http://api.jquery.com/category/ajax/
关于javascript - 在 PHP 中检索 JS 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32249592/