简体   繁体   English

未定义不是函数-SPServices

[英]Undefined is not a function - SPServices

Console Log: 控制台日志:

Uncaught TypeError: undefined is not a function index.html:77
LoadCat index.html:77
(anonymous function) index.html:107
n.event.dispatch jquery.js:3
r.handle

Code: 码:

        function LoadCat(cat) {

        if (cat != null) {

        var CAML = '<Query><Where><Eq><FieldRef Name="Department" /><Value Type="Text">' + cat + '</Value></Eq></Where></Query>';

        }
        else {

        var CAML = '';
        }


    var liHtml = "Category:  <select name=\"categoryselect\" id=\"categoryselect\">";

    $().SPServices({
        operation: "GetListItems",
        async: false,
        webURL: "PSS/StaffShop/",
        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") + "\" >" + $(this).attr("ows_Title") + "</option>";


            });
            liHtml = liHtml + "</select>";
            $("#cat").html(liHtml);
        }

    });
    }

Code call: 代码调用:

$('.area').click(function(){ 

alert($(this).attr("href")); 

LoadCat();

});

The code is failing on this line: 代码在此行失败:

   $().SPServices({

However 然而

- JQuery is loaded
- SPServices is loaded
- Function is called in document ready

Full code is here for those interested: http://pastebin.com/NvSCjV72 对于那些感兴趣的人,这里是完整的代码: http : //pastebin.com/NvSCjV72

EDIT: 编辑:

It seems that SPServices reference is being lost on click? 似乎单击时丢失了SPServices参考?

Can anyone shed any light on this? 谁能对此有所启示?

定义了两次jQuery,这导致SPServices无法正确加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM