jQuery Deferred and promise-错误:对象没有't支持属性或方法'然后'
jQuery Deferred and promise - Error: Object doesn't support property or method 'then'
我可能遗漏了一些非常基本的东西,但我似乎找不到错误,这让我很沮丧。我只是想从我的开发SharePoint网站上提取列表(然后是项目,但每次一件事)。
我已经构建了第一个延迟方法,控制台日志显示它完成了,但随后我得到了"错误:对象不支持属性或方法'then'",就好像jQuery以某种方式失败了一样。
为了参考,我试图遵循这里描述的方法:http://www.shillier.com/archive/2013/03/04/using-promises-with-the-javascript-client-object-model-in-sharepoint-2013.aspx
这是代码:
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(function () {
GetSiteLists.bListsGotten().then(
function (oWebLists) {
// Get Lists Succeeded
alert('Lists Retrieved');
}
, function (sender, args) {
// Get Lists Failed
alert('Lists Not Retrieved');
}
);
});
GetSiteLists = function () {
var bListsGotten = function () {
var deferred = $.Deferred();
var oContext = new SP.ClientContext.get_current();
console.log('oContext instantiated');
var oWeb = oContext.get_web();
console.log('oWeb instantiated');
this.oWebLists = oWeb.get_lists();
console.log('oWebLists command set');
oContext.load(this.oWebLists);
console.log('context load command set');
oContext.executeQueryAsync(
Function.createDelegate(this,
function () { deferred.resolve(this.oWebLists); }),
Function.createDelegate(this,
function (sender, args) { deferred.reject(sender, args); }));
console.log('list retrieval query executed async');
console.log('returning promise');
return deferred.promise;
}
return {
bListsGotten: bListsGotten
}
}();
</script>
promise
是一个函数,您没有调用它。
return deferred.promise()
会解决的。
相关文章:
- JQuery示例不起作用-“;对象没有't支持属性或方法'按钮'&”;
- 对象不支持属性或方法“自动完成”
- SCRIPT438:对象没有't支持属性或方法'endsWith'在IE10中
- 对象没有't支持属性或方法'transformNode'在Internet Explorer 1
- jQuery Deferred and promise-错误:对象没有't支持属性或方法'然后'
- 如何修复错误'对象没有't支持属性或方法'getScreenCTM''在Inter
- 对象不支持属性或方法“确认”
- 对象不支持属性或方法“jscomp_symbol_iterator0”
- 下拉 Javascript 错误:对象不支持属性或方法“匹配”
- 运行时错误:对象不支持属性或方法
- Ember 1.0 预发行版支持属性是否已更改
- 对象没有't支持属性或方法'querySelectorAll'(sp.core.debug.js
- MVC4和日期选择器:“;0x800a01b6-JavaScript运行时错误:对象没有't支持属性或方法
- Microsoft JScript运行时错误:对象没有't支持属性或方法'html'
- 为什么下面抛出一个“;对象没有't支持属性或方法'importNode'"在IE11中
- jPlayer和IE10-SCRIPT438:对象没有't支持属性或方法'jPlayer'
- 对象没有't支持属性或方法'loadFull'
- "Function.createDelegate"原因;错误:对象没有't支持属性或方法
- IE9:对象不支持属性“is”
- IE 错误 .JavaScript 运行时错误:对象不支持属性或方法“preventDefault”