我试图将变量从我的javascript代码传递到服务器端PHP代码。我知道这必须通过ajax调用来完成,我相信我已经正确地完成了,但是访问变量是从我的ajax传递到我的php时遇到的麻烦,因为我是php的新手。到目前为止,这是我的代码:
$(document).ready(function() {
$(".clickable").click(function() {
var userID = $(this).attr('id');
//alert($(this).attr('id'));
$.ajax({
type: "POST",
url: 'logtime.php',
data: "userID=" + userID,
success: function(data)
{
alert("success!");
}
});
});
});
<?php //logtime.php
$uid = isset($_POST['userID']);
//rest of code that uses $uid
?>
我正在尝试将我的JavaScript变量“ userID”传递给php($ userID),但是在此过程中出现了问题。谢谢您的帮助!
哔哔one
蓝山帝景