How do i create something such as the Facebook LIKE hyperlink which enables me to update mysql database without refreshing the page? Quite simply , I want this hyperlink to update the database after i click it and display the number of likes is saved in DB without page refresh. Thanks in advace.

In plain simple words, you will have to use AJAX, that will get fired whenever you click on the hyperlink, using JavaScript.

You will find these choices to use AJAX:-

  1. Use JavaScript own functions to fireplace AJAX.
  2. Use JavaScript libraries, like jQuery, Prototype, and more.

Undoubtedly, jQuery will suit every novice to the best &lifier you are able to take a look in here for additional particulars on AJAX.

Hope it will help.

I'd suggest the AJAX approach but simply to say it, the result might be accomplished without AJAX by placing the button within an iframe, this iframe could then stick to the the hyperlink with no page needing to refresh.

in even simpler words than my predecessor

this is exactly what you've


a href='somewhereOverTheRainbow'>LikeThis...

this is exactly what you ought to have


var likeIt=function(myAnchorElem)take your pick - or perhaps a stand alone ajax lib


    //avoid the default

    return false


a href='somewhereOverTheRainbow' onclick='return likeIt(this)'>LikeThis...

@javascriptWizards I understand, he should use addEventListener rather to then obtain a real event which he is able to call preventDefault and much more.

near the ajax way, you could utilize json-p, an img or perhaps an iframe as well as by utilizing websockets. However for simplicity and ease, stick to the ajax way!

generally creating a feature like the facebook like or google "+1" seams very trivial. The simple truth is not even close to it's is among the harder things you can do within the web! The Frontend for this is simple like cake. However the After sales... wanting your site to scale and demanding/requiring normal database respond occasions will take you onto the knees