1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Click Counter using Ajax Tutorial?

Discussion in 'JavaScript' started by stlgolfforum, Oct 18, 2012.

  1. #1
    Hey everyone,

    I've been searching the web for awhile now trying to find a tutorial on making a click counter that registers clicks and saves them so that on a refresh they don't get reset. I also want it to add the count in real time (using ajax). I also want it to keep a user from clicking more than once on the same button.

    Here is a example of exactly what I want... http://www.twitrcovers.com/

    Notice under each image is a counter that you can only vote or click on once.

    Is there a tutorial out there for this? I'm not very advanced when it comes to javascript and ajax (i'm front end guy so i'm used to css, html, and php)

    Any help would be great, thanks!
     
    stlgolfforum, Oct 18, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    The problem isn't your lack of knowledge of AJAX, it's your lack of knowledge of programming.

    On a click, check (using AJAX) whether this user has clicked on this button. If not, tell the server (via AJAX) to increment the count for this button and to mark this user as having clicked on this button. (You can use the user's IP address ad "this user". It's not guaranteed, but it's about the best you can do on the web. Sending the user a cookie would also work, but if the user has cookies disabled or blocked, it won't.) Use the database to store the data.

    As far as an AJAX tutorial, just search for ajax tutorial - there are thousands of them. (Using jQuery, if you're already using it or if you want to add it, makes AJAX almost trivial, but writing AJAX code manually isn't much work.) You'll also have to learn Javascript, since that's the browser side of AJAX. (PHP is the server side.)
     
    Rukbat, Oct 28, 2012 IP