Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node cannot be inserted at the specified point in the hierarchy

Tags:

jquery

ajax

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.

like image 247
Ber53rker Avatar asked Nov 16 '11 22:11

Ber53rker


2 Answers

Try specifying a dataType:

$("#button").click(function(){
   $.ajax({
      url:"AjaxRequest.html",
      dataType:'html',
      success:function(data) {
        $("#content").html(data);
      }
   });
});
like image 184
Jeff Lauder Avatar answered Nov 07 '22 03:11

Jeff Lauder


try

$("#content").append('<p>'+data+'</p>'); 
like image 30
Gjohn Avatar answered Nov 07 '22 03:11

Gjohn