none
这里太冷清了,分享 Jquery 向 office365 sharepoint2013 list插入数据 RRS feed

  • 常规讨论

  • html>  
    <head>  
    <TITLE>FeedBack</TITLE>  
    <META content="text/html; charset=utf-8" http-equiv=Content-Type>  
    <SCRIPT type=text/javascript src=" /jquery-1.9.1.min.js"></SCRIPT>    
    <SCRIPT type=text/javascript src=" /JS/knockout-3.1.0.js"></SCRIPT>  
    <SCRIPT type=text/javascript src=" /JS/json2.js"></SCRIPT>  
      
    </head>  
    <body>  
      
    <script type="text/javascript">  
    function executeFeedback(url, type, verb, data, success, error) {    
          $.ajax({    
            url: "https://xxxx.sharepoint.com/xxxx/_api/web/lists/GetByTitle('ListNAME')/" + url,    
            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": verb    
            },    
            cache: false,    
            success: success,    
            error: error    
          });    
        }    
        
        function retriveListItem(condition) {  
          executeGlossary(    
            "items?$filter=startswith(Title,'"  + condition + "')&$select=Title,Description",    
            "GET",    
            "GET",    
            null,    
            function (data, status, xhr) {    
              $("#result").empty();    
              for (var i = 0; i < data.d.results.length; i++) {    
                var item = data.d.results[i];  
                $("#result").append("<font style='TEXT-DECORATION: underline'><b>" + item.Title + "</b></font>" + "--" + item.Description +  "<br/>");    
                  
              }    
            },    
            function (xhr, status, error) {    
              $("#result").empty().text(error);    
            });    
        }   
      
        function createListItem() {    
             
          executeFeedback(    
            "items",    
            "POST",    
            "POST",    
            JSON.stringify(    
            {    
                __metadata: { type: "SP.Data.'ListNAME'ListItem" },    
              Title:'123',    
              CurrentStage:'123456789'    
                  }),    
            function (data, status, xhr) {    
              alert('successful');  
            },    
            function (xhr, status, error) {    
              $("#result").empty().text(error);    
            });    
        }   
    </script>  
    <div id="result" style="width:100%; margin-top:15px; margin-left:25px">  
    <input type="button" id="feedbackbtn" value="Save" onclick="createListItem()"/>  
    </div>  
    </body>  
    </html>  
    

    2014年5月12日 11:51

全部回复