So I'm trying to load plain text from an outside file into my page and I keep getting the error in the title. What am I doing wrong? (I followed the tutorial exactly!) Thanks.
HTML
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="ajax.js"></script>
</head>
<body>
<input id="button" type="button" value="Load" />
<div id="content"></div>
</body>
</html>
JQuery
$("#button").click(function(){
$.ajax({
url:"AjaxRequest.html",
success:function(data) {
$("#content").html(data);
}
});
});
EDIT: It is apparently no successful. Not sure why, the file is there right next to it.
Try specifying a dataType:
$("#button").click(function(){
$.ajax({
url:"AjaxRequest.html",
dataType:'html',
success:function(data) {
$("#content").html(data);
}
});
});
try
$("#content").append('<p>'+data+'</p>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With