Mmhhhh ...您有关于这些库的任何文档吗?如果quickAddListItem
不是异步的,那么您将无法完成您想要实现的目标。或者您可以尝试先显示加载图像,然后调用setTimeout
:
$('.my_loading_img').show();
// 500 means to wait 500ms before doing the adding... you can try a smaller number
setTimeout(function() {
var list = new SPAPI_Lists("ListURL");
var newItem = {
Title: "News",
Link: "LinkURL"
};
var items = list.quickAddListItem("List ID", newItem);
}, 500);
否则,我创建了一个处理 Sharepoint webservices 的 JS 库:http: //aymkdn.github.io/SharepointPlus/
用我的图书馆和你的例子:
// show your loading image
$('.my_loading_img').show(); // jquery
// call SharepointPlus
$SP().list("ListName").add({Title:"News",Link:"LinkURL"},
{
error:function(items) {
alert("Error when adding the item");
$('.my_loading_img').hide(); // hide the image
},
success:function(items) {
alert("Item added!");
$('.my_loading_img').hide(); // hide the image
}
}
);