3

I'm trying to access the contents of a library on SharePoint and I can't because the ajax call is returning some kind of error I can't understand.

I hope someone can help me ! The error is the following : enter image description here

the code that is executing the call is the following :

enter image description here

Hope somebody can help me, my mind is blowing up with this.

Thanks a lot!

EDIT 1: Below is code I am using

    <script
      src="https://code.jquery.com/jquery-2.2.4.min.js"
      integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
      crossorigin="anonymous"></script>

    <script           src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.2/jquery.SPSer    vices-0.7.2.min.js"></script>


   <script>

   $(document).ready(function() {
     $().SPServices({
       webURL: "https://xxx.xxx.com/",
       operation: "GetListItems",
       async: false,
       listName: "XXX Xxxxxx",
       completefunc: function (xData, Status) {
           //<em>complete function</em>
       }
     });
   });

   </script>

2 Answers 2

3

First I would comment out the CAMLQuery line and execute the call to ensure it is functioning properly. I'm pretty sure this is where the problem is, it is malformed.

After verifying that works, then it is simply doing this:

var myQuery = "<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>";                 

$().SPServices({
    webURL: "your url"
    operation: "GetListItems",
    async: false,
    listName: "ListName",
    CAMLRowLimit: 100,
    CAMLQuery: myQuery,
    completefunc: function (xData, Status) {
       $(xData.responseXML).SPFilterNode("z:row").each(function() {
         //do something
       });
    }
});
1
  • Please Check the edit i've done, i've tried what you said. The code i'have run is in the edit! Thank you for your anwser! Commented Nov 23, 2016 at 13:55
0

Your webURL should be a relative path to the site which contains the list, so simply "/" if it's the root site.

You're not actually showing the error you're getting, so it's very hard to suggest much of anything else. If you look in the network tab of your browser tools, you should be able to expand the error text.

Finally, you're not actually trying to do anything with the response, so even if the call worked, you wouldn't really know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.