将ListItem插入List [英] Insert the ListItem to List
问题描述
我正在为共享点部署开发共享点应用程序 在我的视觉工作室。我正在尝试将列表项插入现有的 分享点网站列表。 部署我的应用程序到办公室共享点网站后, 并访问我的应用程序似乎
到 清单。 该商品无法添加。
I am developing share point app for share point deployment in my visual studio. I am trying to insert the list item to existing share point site List. After the deployment my app to office share point site, and access my app and seem to the list. The item can't be added.
我附上了我的代码 我的代码有什么问题可以任何人 建议我。
I attached my code what's wrong in my code could anybody advise to me.
< script type =" text / javascript" src =" ../ Scripts / jquery-1.9.1.min.js">< / script>
< script type =" text / javascript" SRC =" ../脚本/ jquery.SPServices.js">< /脚本>
<script type="text/javascript" src="../Scripts/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.SPServices.js"></script>
<脚本类型= QUOT;文本/ JavaScript的">
var vTitle =" xxxxxxxxxxx";
<script type="text/javascript">
var vTitle = "xxxxxxxxxxx";
$(document).ready(function(){
$('#btnSubmit')。click (函数(){
$(document).ready(function () {
$('#btnSubmit').click(function () {
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; $()。 SP服务(
{
  ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;操作:" UpdateListItems" ;,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;异步:假,
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; WEBURL:" https://开头evxxxxxxxx。 sharepoint.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BSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; }
});
$().SPServices(
{
operation: "UpdateListItems",
async: false,
webURL: "https://evxxxxxxxx.sharepoint.com/sites/Developer/",
batchCmd: "New",
listName: "TestList",
valuepairs: [
["Title", vTitle]
],
completefunc: function (xData, Status) {
alert("Saved Successfully");
}
});
});
$
});
});
});
< / script>
</script>
谢谢和问候
brite
britekumar
britekumar
推荐答案
我可以在SharePoint托管应用程序中调用SPServices时重现此问题,它会抛出此错误浏览器控制台:
I can reproduce this issue when calling SPServices in the SharePoint hosted app, it will throw this error in browser console:
这是因为SharePoint应用程序是跨域的,因此它不会直接访问主机Web中的lists.asmx。从UserVoice的检查同样的问题:
This is because the SharePoint app is cross domain so it won't access the lists.asmx in host web directly. Check this same issue from UserVoice:
我们需要使用跨域库和Rest API要在SharePoint App中处理跨域调用,请查看以下演示:
We need to use Cross Domain library and Rest API to handle Cross Domain call in SharePoint App, check the demo below:
Manipulating list items in SharePoint Hosted Apps using the REST API
谢谢
这篇关于将ListItem插入List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!