读取联合项目时出错:“根级别的数据无效。第1行,位置1。'

时间:2018-11-29 18:23:37

标签: javascript jquery ajax sharepoint sharepoint-2010

第一次在这种环境下玩:Sharepoint2010。我只能使用非常有限的工具:浏览器,记事本和Internet。感觉有点生锈,已经有一段时间没有编程了,我现在有一种失落的感觉。

尝试使用AJAX读取SP列表。根据标题,我已达到此400错误的请求错误。这是我在控制台中收到的错误:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-CA">Error reading syndication item: 'Data at the root level is invalid. Line 1, position 1.'.</message>
</error>

以下是我的请求,以及我要阅读的列表的源代码。

我正在尝试将列表读入javascript var中,但是如果我无法通过400错误,我就会被卡住。谢谢任何可以纠正我的人。

这是我的要求:

function getRFCList(){
  var data = "_vti_bin/listdata.svc/RFCExtract";
  var url = BASE_URL + data;
  var thing = {};
    thing.title = "LinkTitle";
    var body = Sys.Serialization.JavaScriptSerializer.serialize(thing);

  console.log(url); //checked url it loads the list correctly

  $.ajax({
        type: "POST",
        url: url,
        processData: false,
        contentType: "application/atom+xml",
        data: body,
        error: function(ts) {    
                    console.log(ts.responseText); 
                    console.log(ts);
               },
        success: function (data) {
                alert(data);
               }
        });
  };

这是加载列表的网址的源代码。

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="<**BASE_URL**>/_vti_bin/listdata.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">RFCExtract</title>
  <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract</id>
  <updated>2018-11-29T12:43:44Z</updated>
  <link rel="self" title="RFCExtract" href="RFCExtract" />
  <entry m:etag="W/&quot;1&quot;">
    <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(1)</id>
    <title type="text">Test</title>
    <updated>2018-11-28T15:07:57-05:00</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="RFCExtractItem" href="RFCExtract(1)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(1)/CreatedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(1)/ModifiedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(1)/Attachments" />
    <category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
        <d:Title>Test</d:Title>
        <d:Class m:type="Edm.Double">1</d:Class>
        <d:Status>Closed</d:Status>
        <d:Date m:type="Edm.DateTime">2010-11-01T00:00:00</d:Date>
        <d:RFCNumber m:type="Edm.Double">1</d:RFCNumber>
        <d:Id m:type="Edm.Int32">1</d:Id>
        <d:ContentType>Item</d:ContentType>
        <d:Modified m:type="Edm.DateTime">2018-11-28T15:07:57</d:Modified>
        <d:Created m:type="Edm.DateTime">2018-11-28T15:07:57</d:Created>
        <d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
        <d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
        <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
        <d:Version>1.0</d:Version>
        <d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
      </m:properties>
    </content>
  </entry>
  <entry m:etag="W/&quot;1&quot;">
    <id><**BASE_URL**>/_vti_bin/listdata.svc/RFCExtract(2)</id>
    <title type="text">Test Record 2</title>
    <updated>2018-11-29T07:42:19-05:00</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="RFCExtractItem" href="RFCExtract(2)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" type="application/atom+xml;type=entry" title="CreatedBy" href="RFCExtract(2)/CreatedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="RFCExtract(2)/ModifiedBy" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="RFCExtract(2)/Attachments" />
    <category term="Microsoft.SharePoint.DataService.RFCExtractItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ContentTypeID>0x010018E49BFAAA76C74C8D9E319D13220A60</d:ContentTypeID>
        <d:Title>Test Record 2</d:Title>
        <d:Class m:type="Edm.Double">2</d:Class>
        <d:Status>Pending</d:Status>
        <d:Date m:type="Edm.DateTime">2018-11-02T00:00:00</d:Date>
        <d:RFCNumber m:type="Edm.Double">2</d:RFCNumber>
        <d:Id m:type="Edm.Int32">2</d:Id>
        <d:ContentType>Item</d:ContentType>
        <d:Modified m:type="Edm.DateTime">2018-11-29T07:42:19</d:Modified>
        <d:Created m:type="Edm.DateTime">2018-11-29T07:42:19</d:Created>
        <d:CreatedById m:type="Edm.Int32">9929</d:CreatedById>
        <d:ModifiedById m:type="Edm.Int32">9929</d:ModifiedById>
        <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
        <d:Version>1.0</d:Version>
        <d:Path>/sp/CCSB/Lists/RFC Extract</d:Path>
      </m:properties>
    </content>
  </entry>
</feed>

0 个答案:

没有答案