You can try to override the default function of the event, by using this code,
event.preventDefault();
.. write this line inside the very first line of the event handler, using which will prevent all of the default functions that it can perform and the remaining code will execute as it should.