我有一个网站托管在一个自定义HTML表单的Apache网络服务器上。我也有一个Sharepoint 2013列表(在同一网络上),我需要自定义HTML表单来添加项目。到目前为止,我一直在研究JS的JS(特别是sp.js等)。通过Apache Web服务器通过Javascript创建Sharepoint 2013列表项目
我也看过在Sharepoint本身上托管窗体,因为它看起来像sp.js期望有一个相对的url,这对Apache服务器没有任何意义,所以更成功。
JS代码到目前为止
function save(){
if(confirm("Are you sure you want to submit this?")){
ExecuteOrDelayUntilScriptLoaded(createListItem, "sp.js");
}
}
function createListItem() {
var siteUrl= "/sites/mysites/site";
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Sandbox');
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('Title', 'My New Item!');
oListItem.set_item('Line Type', 'Type 1');
oListItem.set_item('Amount', '100');
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
alert('Item created: ' + oListItem.get_id());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}
HTML头
<head>
<script src="http://mysite/sites/site/_layouts/1033/init.js" type="text/javascript"></script>
<script src="http://mysite/sites/site/_layouts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="http://mysite/sites/site/_layouts/sp.core.js" type="text/javascript"></script>
<script src="http://mysite/sites/site/_layouts/sp.runtime.js" type="text/javascript"></script>
<script src="http://mysite/sites/site/_layouts/sp.js" type="text/javascript"></script>
<script src="TER.js"></script>
</head>
注意的是,在我的Javascript改变变量SITEURL需要取决于哪个虚拟主机提供商,我目前正在测试上(即绝对或相对)。
有没有人知道我试图做甚至可能或者我需要尝试不同的方法?
托管在Apache的HTML与XMLHttpRequest来进口形式到SharePoint(必须允许在CORS Apache服务器),以及SharepointPlus做了诀窍。谢谢。 – thetechnician94