How to retrieve a json object from a sharepoint li

2019-04-15 22:15发布

I am created myself a custom list with sharepoint 2007, which is exactly the same as any excel spreadsheet in effect.

I was told that i can get this out all of the information as a json or XML object. I don't have access to the file system, only to sharepoint web interface.

Can i just use a url and do my normal getJson?

    $.getJSON("http://somesharepointurl.asp?get=json",function(results){
        console.info(results);
        $.each(results, function(){

        });
    });

Or is there no way of doing this without writing some backend service?

Edit

https://someserver/sites/DisasterRecovery/eventmgmt/DRR/_vti_bin/owssvr.dll?Cmd=Display&List={B0ACA997-8A41-498B-97FE-B276D48F64D7}&XMLDATA=TRUE

I have tried this... it gave me this:

HTTP/1.1 200 OK
Server: Microsoft-IIS/7.5
Date: Fri, 14 Dec 2012 11:41:55 GMT
Connection: close

No idea what to look for whatsoever i'm afraid :(

4条回答
相关推荐>>
2楼-- · 2019-04-15 22:43

Another option, in sharepoint 2010 try use the OData like these : http://webname/_vti_bin/ListData.svc/listname , and the feature of filter and sort is same as standard OData, refference can be found here: http://www.odata.org/documentation

查看更多
forever°为你锁心
3楼-- · 2019-04-15 22:47
  1. SharePoint 2007 doesn't provide you with JSON formatted results, only SOAP/XML web services and the URL Protocol you refer to in the update
  2. Make sure you append the /_vti_bin part to the address of the correct subsite, rather than the library (although if you made this error, you'd get 404)
查看更多
姐就是有狂的资本
4楼-- · 2019-04-15 22:56

Found the simple answer:

jquery.SPServices

you will need jQuery 1.4.2+ to run this but its fantastic :) It has many more method's than just getting XML or json back.

 var query = "<Query><OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy</Query>";
 $().SPServices({
     operation:"GetListItems",
     async:false,
     listName:"Home Page Carousel",
     CAMLViewFields:"<ViewFields><FieldRef Name='userName'/><FieldRef Name='userDepartment'/><FieldRef Name='message'/></ViewFields>",
     CAMLQuery:query,
     CAMLRowLimit:10,
     completefunc:function (xData, Status) {
     console.info(xData);
     console.info(Status);
         $(xData.responseXML).SPFilterNode("z:row").each(function () {
             var $this = $(this);
             $this.attr("ows_message")//retrieve list data here and do stuff here
         });
     }
 });

This will return you a lovely chunk of XML .

查看更多
不美不萌又怎样
5楼-- · 2019-04-15 23:01

Try to add &Query=* to the URL query string

查看更多
登录 后发表回答