Skip to content

Instantly share code, notes, and snippets.

@Colt
Created October 7, 2013 21:03
Show Gist options
  • Select an option

  • Save Colt/6874912 to your computer and use it in GitHub Desktop.

Select an option

Save Colt/6874912 to your computer and use it in GitHub Desktop.
Ajax Movies Lab
$(function(){
//alert("JQUERY LOADED!");
//CHANGE THE DEFAULT BEHAVIOR OF THE FORM
$('form').on("submit", function(event) { //do something whenever a form is submitted
event.preventDefault(); //prevents the default submit behaviour. no longer refreshes page.
var searchTerm = $('input').val(); //targets the only input and saves its value
alert(searchTerm);
});
//end of form code
});
<!doctype html>
<html>
<head>
<title>My Movies APP</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="script.js">
</script>
</head>
<body>
<div class="movie-detail"></div>
<!-- Form for searching movies -->
<form>
<input type="text"> //do something whenever a form is submitted
<button>Search</button>
</form>
<!-- Display Results -->
<div class="results"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment