我需要获取以下代码才能将$ Bus_Account_ID和$ Usr_ID传递给include文件rating2.php
$Bus_Account_ID=733;
$Usr_ID=3;
我不熟悉AJAX所以在这里学习。 我相信这是传递给包含的线路,但我不知道发生了什么" attrVal"
data: 'postID='+attrVal+'&ratingPoints='+val,
$(function() {
var value = "<?php echo $total_points ?>";
$("#rating_star").codexworld_rating_widget({
starLength: '5',
initialValue: value,
callbackFunctionName: 'processRating',
imageDirectory: 'images/',
inputAttr: 'postID'
});
});
function processRating(val, attrVal){
$.ajax({
type: 'POST',
url: 'rating2.php',
data: 'postID='+attrVal+'&ratingPoints='+val,
dataType: 'json',
success : function(data) {
if (data.status == 'ok') {
$('#avgrat').text(data.total_points);
$('#totalrat').text(data.rating_number);
}else{
alert('Some problem occured, please try again.');
}
}
});
}
postid仅在上面和此处显示3个位置
<input name="rating" value="0" id="rating_star" type="hidden" postID="1" />
这是在包含文件
上调用的内容$postID = $_POST['postID']; /* BUSINESS ID */
如何调用$ Bus_Account_ID和$ Usr_ID?
答案 0 :(得分:1)
你在这里传递数据有问题..,你需要保持这样的格式:data: { name: "John", location: "Boston" }
$.ajax({
type: 'POST',
url: 'rating2.php',
data: 'postID='+attrVal+'&ratingPoints='+val,
所以改变数据,
data: { postID: attrVal, ratingPoints: val, Usr_ID : "<?php echo $Usr_ID;?>", Bus_Account_ID : "<?php echo $Bus_Account_ID;?>" }