This is driving me nuts. This is as simple an example as it can get. All the links are absolute so you should literally be able to copy this into a file called "test.html", load it up, hit submit, and see the word "empty" be changed to the results of http://www.w3schools.com/php/welcome.php.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#create').submit(function() {
$.ajax({
data: $(this).serialize(),
type: $(this).attr('method'),
url: $(this).attr('action'),
success: function(response) {
$('#created').html(response);
}
});
return false;
});
});
</script>
</head>
<body>
<form id="create" method="POST" action="http://www.w3schools.com/php/welcome.php">
<input type="submit" value="Submit" />
</form>
<div id="created">empty</div>
</body>
</html>
When I click Submit, nothing happens. What am I doing wrong?