Reputation: 87
I need to get the following code to pass the $Bus_Account_ID and the $Usr_ID to the include file rating2.php
$Bus_Account_ID=733;
$Usr_ID=3;
I am not familar with AJAX so learning here. I believe that this is the line passing to the include but I don't know what is happening with "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 shows in only 3 place in the above and here
<input name="rating" value="0" id="rating_star" type="hidden" postID="1" />
This is what is being called on the include file
$postID = $_POST['postID']; /* BUSINESS ID */
How to I call the $Bus_Account_ID and the $Usr_ID?
Upvotes: 0
Views: 59
Reputation: 9583
You have the problem with passing the data here.., You need to maintain the format like this: data: { name: "John", location: "Boston" }
$.ajax({
type: 'POST',
url: 'rating2.php',
data: 'postID='+attrVal+'&ratingPoints='+val,
So change the data by,
data: { postID: attrVal, ratingPoints: val, Usr_ID : "<?php echo $Usr_ID;?>", Bus_Account_ID : "<?php echo $Bus_Account_ID;?>" }
Upvotes: 1