Need ya help

i can't figure it out. i am working on a q&a webpage and i want to make an upvote/downvote system.

How or what should i use to save when a user upvotes a question on a database without needing to refresh the page.

I have no ideea ><

PS: as backend i use php and mysql for the database

  • 0
    Nvm found that AJAX is quite useful

    i still haven't figure it out but i fell that i am close
  • 4
    JS Ajax
    Call a server side script
    Save data
    Return response (success / fail )

    JS does something with response, like display “thank you for voting” or something
  • 1
    - Implement an async vote request placed from the client side to a server end API.

    - POST something like a JSON object to the server:

    post_id : 12345,
    upvote : 1,
    downvote : 0,
    user_id : 123,
    auth_token : 'blahblah'

    - Only allow one vote per user....+1/-1

    - Block user from voting on his/her own posts.

    - Avoid displaying messages after every vote as it may get annoying.

    (Instead you can do something like, change colors on the vote counter to green for upvote and red for downvote)
  • 1
    @bigus-dickus i like the ideea and had almost everything u said set in my mind
    Thank you for being clear :D
Add Comment