I am learning jQuery on codeschool. All the way through the ajax lessons i could not get it to work. Please can somebody give me a push in the right direction. Thanks in advance.
Here is a jsfiddle..
https://jsfiddle.net/w202usyk/
and here is my code..
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Where's Aggie???</title>
<script type="text/javascript" src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<link type="text/css" href="main2.css" rel="stylesheet">
</head>
<body>
<button class="btn"> Click Here</button>
<div class='headbox'>
<p class='main-title'>A</p>
</div>
</div>
<script type="text/javascript" src="application2.js"></script>
</body>
</html>
My js..
$(document).ready(function() {
$('button').on('click', '.btn', function(){
$.ajax('http://www.jamesleetaylor.com/wheresaggie/b.html', {
success: function(response) {
$('.main-title').replaceWith(response);
}
});
});
});
and CSS
.btn {
margin-bottom: 20px;
}
.main-title {
text-align: center;
}
.headbox {
width: 100px;
border: 3px solid black;
}