【发布时间】:2011-03-04 03:42:57
【问题描述】:
我正在使用 jQuery 并为一些内部工作制作了一个插件,该插件基本上为我们的内部 API 构建 URL。无论如何,我想返回 $(this) 并且我没有得到正确的东西并且我得到一个 createdocumentfragment 错误?
插件代码:
$.get(base_url,{
agenda_id:defaults.id,
action:defaults.action+defaults.type,
output:defaults.output
},function(html){
defaults.callback(html);
});
这很好,但我想像这样添加 return obj:
$.get(base_url,{
agenda_id:defaults.id,
action:defaults.action+defaults.type,
output:defaults.output
},function(html){
defaults.callback(html);
return obj;
});
Obj 是在我的插件开始时设置的,并且 obj 在整个插件中都可以正常工作。设置为obj=$(this);
在我使用插件的脚本中,我有:
$('#agenda-live-preview').agenda({action:'get',type:'agenda',id:window.location.href.split('/').pop(),callback:function(html){
$(this).empty().append($(html).html());
}});
但是,它不起作用并返回:
Error: doc.createDocumentFragment is not a function
Source File: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
Line: 4373
在控制台错误日志中。任何想法如何返回 $(this) 并运行回调?
【问题讨论】:
标签: javascript jquery html json jquery-plugins