Just to give a background. I wrote the below code in a normal html file. With no server or anything running on my system. I created a file on the desktop and wrote the html code in there.
First Method
<form action="http://www.google.com" method="GET">
<input type="submit"/>
</form>
Second Method
<form action="http://www.google.com" method="GET">
<input type="button" onclick="myMethod()"/>
</form>
<script>
function myMethod(){
$.ajax({
data:'',
type: 'GET',
url: 'http://www.google.com',
success: function(response){
$(".popupdiv").html(response);
}
});
event.preventDefault();
return false;
}
</script>
When I do the first method, on clicking the button, I get taken to the google.com
but by second method, nothing happens. Even my (chrome)console does not show any error.
What is happening and what is the difference?