I'm working on a form that writes to a SharePoint list when submitting as a new entry in the list.(我正在处理一个表单,该表单在列表中作为新条目提交时会写入SharePoint列表。)
I've got the AJAX code in place and it seems to connect out to the list okay, however I'm receiving the following error when attempting to create the entry:(我已经准备好了AJAX代码,似乎可以连接到列表了,但是尝试创建该条目时收到以下错误:)
SCRIPT5009: 'data' is not defined
Here's my code, the data is pulled from the text boxes in the form, I'm just not certain whether they've been added to the JSON array properly.(这是我的代码,数据是从表单中的文本框中提取的,我不确定它们是否已正确添加到JSON数组中。)
function AddListItem() {
var ref = $("#ref").val();
var userID = $("#userID").val();
var impact = $("#impact").val();
$.ajax
({
url: "https://office4.bt.com/sites/ccim/Portal/_api/web/lists/GetByTitle('ImpactFeedback')/items",
type: "POST",
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.TestListItem"
},
Title: ref,
UIN: userID,
Issue: impact,
Email: email,
}),
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
success: function(data, status, xhr)
{
retriveListItem();
},
error: function(xhr, status, error)
{
$("#ResultDiv").empty().text(data.responseJSON.error);
}
});
}
ask by GetWhimsical translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…