无法使用RES API检索列表项 [英] Unable to retrieve list items using RES API

查看:59
本文介绍了无法使用RES API检索列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的

我正在使用下面的代码来检索列表项以及

I am using below code to retrieve list items along with SP.UI.ModalDialog function .

Can any one please do let me know what's wrong in my below code.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myfunction);
        function myfunction() {
            var dialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Processing...', 'Request is in progress...', 80, 300);
            retriveListItem().done(function (data) {
                dialog.close(0);
                dialog = null;
                //processing your data
                alert(data.d.results.length);
            });
        }

        function retriveListItem()
        {

          $.ajax
          ({
          url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Orderdetails')/items?Select=Title&$orderby=Order0"
          type: type,
          data: data,
          headers:
          {
              "Accept": "application/json;odata=verbose",
              "Content-Type": "application/json;odata=verbose",
              "X-RequestDigest": $("#__REQUESTDIGEST").val(),
              "IF-MATCH": "*",
              "X-HTTP-Method": null
          },
          cache: false,
          success: function(data)
          {
              $("#divHelloWorld").empty();
              for (var i = 0; i < data.d.results.length; i++)
              {
                  var item = data.d.results[i];
                  $("#divHelloWorld").append(item.Title  "<br/>");
              }
          },
          error: function(data)
          {
              $("#divHelloWorld").empty().text(data.responseJSON.error);
          }
      });
  }
    </script>
    <p id="divHelloWorld">Hello World!</p>

SP评估

推荐答案

请尝试使用此代码,我删除了ajax调用方法的类型和数据参数.将网址替换为您的网址

Please try this code,I removed the type and data parameter on ajax call method.Replace the url with yours

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', myfunction);
        function myfunction() {
            var dialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Processing...', 'Request is in progress...', 80, 300);
            retriveListItem().done(function(data) {
               
            dialog.close(0);
                dialog = null;
                //processing your data
                alert(data.d.results.length);
                        });
                        }

        function retriveListItem()
        {


.ajax ({ 网址:_spPageContextInfo.webAbsoluteUrl +``/_api/web/lists/GetByTitle('Accounts')/items, 标头: { "Accept":"application/json; odata = verbose", "Content-Type":"application/json; odata = verbose", "X-RequestDigest":
.ajax ({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Accounts')/items", headers: { "Accept": "application/json;odata=verbose", "Content-Type": "application/json;odata=verbose", "X-RequestDigest":


(" #__ REQUESTDIGEST).val(), "IF-MATCH":"*", "X-HTTP-Method":null }, 快取:false, 成功:功能(数据) {
("#__REQUESTDIGEST").val(), "IF-MATCH": "*", "X-HTTP-Method": null }, cache: false, success: function(data) {


这篇关于无法使用RES API检索列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆