SP服务-对象不'我不支持这种方法
SP Services - Object doesn't support this method
当函数被调用时,我在这个函数上得到一个"Object不支持这个方法"错误
function LoadCat(cat) {
if (cat != null) {
var liHtml = "Category: <select name='"categoryselect'" id='"categoryselect'">";
var CAML = '<Query><Where><Eq><FieldRef Name="Department" /><Value Type="Text">' + cat + '</Value></Eq></Where></Query>';
alert(CAML);
} else {
alert(cat);
var CAML = '';
}
$().SPServices({
operation: "GetListItems",
async: false,
webURL: "http://sp-app",
listName: "Categories",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLQuery: CAML,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
liHtml = liHtml + "<option value=''>" + $(this).attr("ows_Title") + "</option>";
});
liHtml = liHtml + "</select>";
$("#cat").html(liHtml);
}
});
}
错误出现在$()上。SPServices({line
当cat为null或有值时,就会发生这种情况。
几个小时来我一直在为这个挠头!
SharePoint服务是在调用函数之前加载的!
似乎只有当我调用这个函数时才会出现错误:
$(".area").click(function () {
$(".area").parent("li").removeClass("active");
$(this).parent("li").addClass("active");
LoadCat();
});
function LoadCat(cat) {
if (cat != null) {
var liHtml = "Category: <select name='"categoryselect'" id='"categoryselect'">";
var CAML = '<Query><Where><Eq><FieldRef Name="Department" /><Value Type="Text">' + cat + '</Value></Eq></Where></Query>';
alert(CAML);
} else {
alert(cat);
var CAML = '';
}
$().SPServices({
operation: "GetListItems",
async: false,
webURL: "http://sp-app",
listName: "Categories",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
CAMLQuery: CAML,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
liHtml = liHtml + "<option value=''>" + $(this).attr("ows_Title") + "</option>";
});
liHtml = liHtml + "</select>";
$("#cat").html(liHtml);
}
});}
$(document).ready(function() {
var subject = "Hi Subject!";
var message = "Hi Message!";
LoadCat(subject);
});
看看浏览器中的javascript控制台,你会发现有用的错误。必须加载jQuery和SPServices。对于您的测试,您甚至可以使用jQuery和SPServices的cdn链接。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
相关文章:
- 对象不支持属性或方法“自动完成”
- javascript表单字段submit:Object dos'在IE8中不支持此属性或方法
- 如何从 MVC4 链接调用 Javascript 方法(错误 JavaScript 运行时错误:对象不支持此操作)
- JSHint 错误“对象不支持此属性或方法”用于 javascript 闭包
- 对象不支持属性或方法“确认”
- 对象不支持属性或方法“jscomp_symbol_iterator0”
- 对象不支持 igGrid 中的属性或方法“_super”
- 下拉 Javascript 错误:对象不支持属性或方法“匹配”
- 运行时错误:对象不支持属性或方法
- Javascript 错误:对象在 IE 浏览器中不支持此属性或方法
- 对象不支持在调用 indexOf 定义的数组时 IE8 中未定义的此属性或方法
- IPAD safari 浏览器不支持 window.open JavaScript 方法
- IE8 TypeError对象没有'不支持方法的此属性
- IE8 Javascript错误:对象没有'不支持此属性或方法
- java脚本错误对象没有'不支持此属性或方法
- 对象没有'在JavaScript中不支持此属性或方法
- 对象不支持此属性或方法 Rails Windows 64 位
- 对象不支持 IE7 jQuery 中的此属性或方法错误
- 对象不支持此属性或方法“同位素”
- 对象不支持此属性或方法 - IE 7/8