http://xiangai.taobao.com
http://shop148612228.taobao.com

HierarchyRequestError:Nodecannotbeinsertedatthespecifiedpointinthe

   在使用$.get()方法时,出现了以上的错误信息:

         HierarchyRequestError: Node cannot be inserted at the specified point in the  hierarchy

        下面是我的源代码

$(document).ready(function() {var pageNum = 1;$('#more-photos').click(function() {var $link = $(this);var url = $link.attr('href');if (url) {$.get(url, function(data) {$('#gallery').append(data);});pageNum++;if (pageNum < 20) {$link.attr('href', 'pages/' + pageNum + '.html');}else {$link.remove();}}return false;});});

       其中,出现错误的就在:

$.get(url, function(data) {$('#gallery').append(data);});

    因为,我请求的是一个html的页面片段,将得到的html片段加载在index页面中,而jQuery.get()方法中漏写了dataType。

    在jQuery中的官网中,datatype默认为:智能匹配。即,由电脑智能猜测你的datatype是什么类型的,很显然,本次没有猜对。

    【解决方法】:很简单,将datatype写上。

$.get(url, function(data) {$('#gallery').append(data);},'html');
posted @ 2013-06-06 20:52  万事俱备就差个程序员  阅读(352)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏