Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 无法在层次结构中的指定点插入节点_Jquery_Ajax - Fatal编程技术网

Jquery 无法在层次结构中的指定点插入节点

Jquery 无法在层次结构中的指定点插入节点,jquery,ajax,Jquery,Ajax,因此,我试图将外部文件中的纯文本加载到我的页面中,但标题中不断出现错误。我做错了什么?(我完全遵循了教程!)谢谢 HTML 编辑:这显然不成功。不知道为什么,文件就在它旁边。试试看 $("#content").append('<p>'+data+'</p>'); $(“#content”).append(“”+data+””); 尝试指定数据类型: $("#button").click(function(){ $.ajax({ url:"AjaxRe

因此,我试图将外部文件中的纯文本加载到我的页面中,但标题中不断出现错误。我做错了什么?(我完全遵循了教程!)谢谢

HTML

编辑:这显然不成功。不知道为什么,文件就在它旁边。

试试看

$("#content").append('<p>'+data+'</p>'); 
$(“#content”).append(“”+data+”

”);
尝试指定数据类型:

$("#button").click(function(){
   $.ajax({
      url:"AjaxRequest.html",
      dataType:'html',
      success:function(data) {
        $("#content").html(data);
      }
   });
});

我猜在$.ajax调用的success函数中返回的数据是一个完整的页面(其中有一个标记)。您需要返回在标记中有效的html。教程不会在主体标记中显示它。当我把标签放进去时,它仍然没有加载。@user1026288这不是John说的。您需要在文档正文中插入有效的内容。这意味着它不能包含
,它们是不可嵌套的。@hobbs抱歉,误读了,尽管我说了“所以我正试图将外部文件中的纯文本加载到我的页面中…”但是的,无论哪种方式都不起作用。谢谢。你能确认点击事件是否被触发吗?您可能需要将代码包装在$(function(){//code goes here})中;很明显,它甚至没有击中那条线。没有成功。它帮助我修复FF中的错误。谢谢
$("#content").append('<p>'+data+'</p>'); 
$("#button").click(function(){
   $.ajax({
      url:"AjaxRequest.html",
      dataType:'html',
      success:function(data) {
        $("#content").html(data);
      }
   });
});