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 8664477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:14:57+00:00 2026-06-12T17:14:57+00:00

I have built a jQuery 5 star rating system, ratings are inserted/stored in database

  • 0

I have built a jQuery 5 star rating system, ratings are inserted/stored in database along with no of hits, I am having a problem in inserting rating into database when any star is clicked repeatedly.

I.e., if a star is continuously clicked the rating does not get inserted but hits get inserted which then effect the new resulting rating.

I need to add some delay or stop the click function to fire again, it would be better if a delay can be added to click function.

I am trying stop click function to fire again this way but its not working.

jQuery:

        $('.u-rating').click(function (e){
    var id = $(this).parent().attr('id');
    var rating = ($(this).index()+1)/2;
        $.ajax({
        type: "POST",
        url:"rating.php",
        data: {rating:rating, id:id},
        cache: false,
        success: function(data1)          
           {
            get_rating();
            $('#u-rating p').html('Rating Submitted');
           }            
         });
            e.preventDefault();
            e.stopImmediatePropagation();
            return false;
     });

How do I stop people from rating multiple times?

  • 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-06-12T17:14:58+00:00Added an answer on June 12, 2026 at 5:14 pm

    I would suggest that your real issue that your backend is registering just the hits but not the ratings – and you should probably focus on fixing the issue, not covering it with a band-aid.

    Nevertheless, to address your question: You can use one() to bind the click handler just one, and then re-bind on every success (and error). See this jsfiddle for an example. Here is the code:

    HTML:

    <button id="button">Vote!</button>​
    

    JS:

    var postClick = function () {
        console.log('click fired!!');
        el = $(this);
        el.prop('disabled', true);
        //var id = $(this).parent().attr('id');
        //var rating = ($(this).index()+1)/2;
        $.ajax({
            type: "POST",
            url:"/echo/json/",
            //data: {rating:rating, id:id},
            cache: false,
            success: function(data1){
                //get_rating();
                //$('#u-rating p').html('Rating Submitted');
                console.log('ajax success, starting timeout peridod. Clicks will not register now, for the next 5 seconds!');
                setTimeout(function() {
                    $('#button').one('click', postClick);
                    el.prop('disabled', false);  
                    console.log('Clicks are re-enabled!');
                }, 5000);
            } 
        });
    }
    
    $('#button').one('click', postClick);
    

    ​

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have built jQuery drop-down menu which is having problems floating over the UI
I have built a dropdown menu system, everything works when tested independently, the problem
I have built a CMS system using jQuery and PHP, it has worked consistently
So I have built a custom dialog JQuery Plugin, but am having issues with
I have built this accordion using the jquery ui accordion plugin, I sort of
I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
I have built a an app in PhoneGap/Cordova and used the JQuery library for
I am using jQuery cycle in combination with a mousewheel plugin. I have built
I have a slideshow built in flash that I want to mimic in jQuery.
I'm trying to have the built in jQuery widgets apply to dynamic content, for

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.