Skip to content

load a page after event.preventDefault()

October 23, 2013

preventDefault is used to disable the default action of an event. like cut copy paste submit clicking a link, if preventDefault is declared, the event attached wouldn’t work.


after declaring the selector of the form, the submit handler is then declared and a function with an event as a parameter. this event is then used to determine which event to disable. in this case the, preventing the submit button to automatically reload. the next line after that, is the function

function funcName() {
	$.get("http://SomeSite.html/session.php", {email: email_submit})
		.done(function() {
			window.location.href = "http://SomeSite.html";

The $.get in JQuery would then first make a pit stop to start a session. after everything is done, the XMLHTTPRequest object returned from the $.get will have a chain .done() attached. this allows us to load after the process in the .get is finished. I didn’t do this the first time and just put the window.location.href after the .get() statement, in which would result for the page to load even if the .get() is not done yet.


From → JQuery

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Children's Book Reviews

Malav Shah

official Web Site

My Road to Programming

The journey of how I taught myself to program.


Look at what's brewing up guys! we all are work in progress. So don't meander, lets micromesh everything and have candid conversation about every problem related to C, C++ and JAVA. We can rejuvenate the crinkled faces.


A simple guide to programming...


Information Techonology

Rahul's Work

My Work Tips and Tutorial on Various Tech.

Turnip Farmers

Kingdom Scans


Technology news, trends and analysis covering mobile, big data, cloud, science, energy and media

The Neighborhood

is under renovation in preparation for our 6th Season


News About Tech, Money and Innovation


The Diary of a Retiree

50 Year Project

My challenge to visit 192 countries, read 1,001 books, and watch the top 100 movies

[BTW] : Ben Trube, Writer

Writer, Programmer, Singer

My Arch Walkthrough

Arch linux made easy

Don Charisma

because anything is possible with Charisma

SutoCom Solutions

Success & Satisfaction with the Cloud

%d bloggers like this: