如何从共享点列表中检索json对象

问题描述:

我自己创建了一个带有sharepoint 2007的自定义列表,它与任何有效的Excel电子表格完全相同。

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

我被告知我可以解决这个问题作为json或XML对象的所有信息。我无法访问文件系统,只能访问sharepoint web界面。

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.

我可以使用网址并执行正常的 getJson

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?

修改

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 :(

找到了简单的答案:

jquery.SPServices

你需要jQuery 1.4.2+才能运行它,但它太棒了:)它有更多的方法,而不仅仅是获取XML或json返回。

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
         });
     }
 });

这将为您提供一小块XML。

This will return you a lovely chunk of XML .