我有这个代码,但我无法使用它。我想要add.php来检索follow var。我对此有些陌生,通常我可以自己或通过大量的谷歌搜索来解决这些问题,但这次我迷失了。
Jquery的:
<SCRIPT>
$(document).ready(function(){
$("#ShowVideoAuthorFollow").click(function(){
$.ajax({
var follow = <?php echo $row['memberid']; ?>;
type: 'POST',
url: 'add.php',
data: { follow:followw },
success: function(response) {
content.html(response);
}
});
});
});
</SCRIPT>
add.php
<?php
session_start();
include ("connect.php");
$sql = "INSERT INTO following (m_id,following)
VALUES ('".$_SESSION['myuserid']."', '".$_POST['follow']."')";
if ($con->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
?>
答案 0 :(得分:0)
快速浏览一下,我发现你正试图在JSON对象文字中声明一个变量。
PS C:\Users\K\desktop\code\Python\Korgan\LearnPythonTheHardWay> py
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
答案 1 :(得分:0)
什么是 content.html(回复)?不应该是 $(“#content”)。html(响应)?
var follow = <?php echo $row['memberid']; ?>;
$(document).ready(function(){
$("#ShowVideoAuthorFollow").click(function(){
$.ajax({
type: 'POST',
url: 'add.php',
data: { follow: follow },
success: function(response) {
$("#content").html(response);
}
});
});
});