Weird Javascript

Just small hint that can help you when hacking JavaScript. Whenever you try to use Ajax, then some strange things may happen. For example page is unintentionally reloaded and return value from Ajax call is lost. When you do that locally you may not even notice that there was double submit.

And the way out... Watch server logs you will see double submit. And avoid it! How as easy as ...href="#" onClick="return yourAjaxFunction(123,'params');"... and of course yourAjaxFunction should return false. Another alternative is to use additional return false at the end of Javascript in onClick.

Comments

Popular Posts