jijo thomas
jijo thomas

Reputation: 337

how to avoid the page reload while using javascript

I am using javascript in a jsp page to make some changes [adding a row in the table] to the current HTML page. The addition is happening successfully, but when i am about to exit from the function the page is getting reloaded.

How to avoid the page reloading and, show the page without any change in the scroll.

Upvotes: 0

Views: 633

Answers (2)

M. Suleiman
M. Suleiman

Reputation: 848

This is a bit vague, we don't know exactly what you are trying to do. However, I think it's better to use jQuery. Or AJAX. Learn jQuery and try to implement your code in jQuery, it's easy, efficient.

jQuery tutorial: http://www.w3schools.com/jquery/default.asp and AJAX tutorial: http://www.w3schools.com/ajax/default.asp

Upvotes: 0

HyderA
HyderA

Reputation: 21371

Add return false at the end of the function if it's an event handler.

I've seen people usually recommend event.preventDefault() but I've personally had it fail on some browsers for me. So not quite sure if that will work just as well.

Upvotes: 1

Related Questions