Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6819659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:19:58+00:00 2026-05-26T21:19:58+00:00

I have this star rating, I implemented from jQuery and I need to save

  • 0

I have this star rating, I implemented from jQuery and I need to save the comments, the user id and the value of the star clicked. What I do not know is how to pass that through the ajax call and what the PHP should have at the least to process the call? Here is my code

stars code – as you can see it has a comments box , the stars with star value and the user id is stored in a variable called

$user_id

Here is the code

<tr>
         <td style="padding:10px;">
         <span style="font-size: 20px; vertical-align:top;">Comments</span>
         </td>
         <td style="padding:10px;">
         <textarea name="comments1" cols="60" rows="2"></textarea>
         </td>
         <td>
         <div>
          <input name="star1" value "1" type="radio" class="star"/>
          <input name="star1" value="2" type="radio" class="star"/>
          <input name="star1" value="3" type="radio" class="star"/>
          <input name="star1" value="4" type="radio" class="star"/>
          <input name="star1" value="5" type="radio" class="star"/> 
          </div>
         </td>
    <tr>

The ajax call – This is the attempted call to the page where I am sending the request, but how can I include the comments and user id on this call?

  $('.star').rating({
        callback: function(value, link) {
           var name = $(this).attr('name');
           $.ajax({
                url: "ajax.php",
                data: "name=" + name + "&value=" + value,
                cache: false,
                success: function(response) {
                    try {
                        console.log(response);
                    } catch (err) {
                        alert(response);
                    }
                }
            });
        }
    });

Now, ajax.php has variables $passed_user_id, $passed_comments, $passed_ratingval. How am I retrieving these values when the call is triggered in php? something like

$passed_comments = //get the value being passed from ajax call
$passed_ratingval = //get the value being passed for the rating value
$passed_user_id = //get the value being passed for the user_id`

I do have all set up, the insert query, connection everything works. I’m just not sure how to make this work with the ajax call.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:19:59+00:00Added an answer on May 26, 2026 at 9:19 pm

    Kinda hacky, but this will work for you. It also will allow for multiple ratings on one page (which I assume you might be doing considering the TR).

    HTML:

    <tr>
      <td style="padding:10px;">
        <input type="hidden" name="userID" value="<?php echo $user_id ?>">
        <span style="font-size: 20px; vertical-align:top;">Comments</span>
      </td>
      <td style="padding:10px;">
        <textarea name="comments" cols="60" rows="2"></textarea>
      </td>
      <td>
        <div>
          <input name="star1" value "1" type="radio" class="star"/>
          <input name="star1" value="2" type="radio" class="star"/>
          <input name="star1" value="3" type="radio" class="star"/>
          <input name="star1" value="4" type="radio" class="star"/>
          <input name="star1" value="5" type="radio" class="star"/> 
        </div>
      </td>
    <tr>
    

    JS:

    $('.star').rating({
      callback: function(value, link) {
        var name = $(this).attr('name');
        var userID = $(this).closest('tr').find('input[name="userID"]').val();
        var comments = $(this).closest('tr').find('textarea[name="comments"]').val();
        $.ajax({
          url: "ajax.php",
          data: "name=" + name + "&value=" + value + "&userID=" + userID + "&comments=" + comments,
          cache: false,
          success: function(response) {
            try {
              console.log(response);
            } catch (err) {
              alert(response);
            }
          }
        });
      }
    });
    

    Also, if you use POST instead of GET, you can format your ajax call a bit nicer like below. Remember to use $_POST[] in your ajax.php file.

    $('.star').rating({
      callback: function(value, link) {
        var name = $(this).attr('name');
        var userID = $(this).closest('tr').find('input[name="userID"]').val();
        var comments = $(this).closest('tr').find('textarea[name="comments"]').val();
        $.ajax({
          url: "ajax.php",
          type: "POST",
          data: {
            name: name,
            value: value,
            userID: userID,
            comments: comments
          },
          cache: false,
          success: function(response) {
            try {
              console.log(response);
            } catch (err) {
              alert(response);
            }
          }
        });
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery star rating. My requirement is to get the value of
I have an application with ajax star rating but when i am assigning value
I already have a 5 star rating system in place (user votes 1-5...and average
I'm adding the star rating plugin from www.fyneworks.com/jquery/star-rating/ and I'm finding the documentation rather
I have this Star Rating system right. When you click on a star it
Right Now I have a 5 star rating with values ranging from 1-5. Behind
I'm using this plugin: http://www.fyneworks.com/jquery/star-rating/ Is it possible to put a click function inside
5 star rating script I have is made based on this tutorial http://php.about.com/od/finishedphp1/ss/rating_script.htm I
I have a around 8 jQuery star rating in my page: <input class= auto-submit-star
i am using jquery star rating plugin . I have a very problem: i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.