我需要得到下面的代码通过$ Bus_Account_ID和$ Usr_ID到包括文件rating2.php与AJAX传递到PHP包括
$Bus_Account_ID=733;
$Usr_ID=3;
我不familar与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.');
}
}
});
}
显示帖子ID仅3在上面,在这里所发生
<input name="rating" value="0" id="rating_star" type="hidden" postID="1" />
这就是被称为上包括文件
$postID = $_POST['postID']; /* BUSINESS ID */
如何调用$ Bus_Account_ID和$ Usr_ID?
'数据:“帖子ID ='+ attrVal +'&ratingPoints ='+ val,'应该是这样的'data:{name:“John”,location:“Boston”}' –
@FrayneKonok - 哈?名字:约翰?位置:波士顿? OP如何工作就好了(语法上) – Marcus
将'data:'postID ='+ attrVal +'&ratingPoints ='+ val,'更改为'data:'postID ='+ attrVal +'&ratingPoints ='+ val +'&userID = <?php echo $ Usr_ID; ?>&busAccountID = <?php echo $ Bus_Account_ID; ?>','你可以分别使用'$ _POST ['userID']'和'$ _POST ['busAccountID']'访问'rating2.php'中的那些。看看这是怎么回事。 – Marcus