使用这个 Javascript:
function upsertPostTravelListItemTravelerInfo1() {
var clientContext = SP.ClientContext.get_current();
. . .
...我有时会收到此错误(并非总是如此,如该方法中的数据插入列表几次(但不是其他时间)所示);浏览器控制台(Chrome 开发工具)中显示的错误消息是:
Uncaught TypeError: Cannot read property 'get_current' of undefined
基于此,我在我的 *.ascx 文件中的 Javascript 顶部尝试了这个:
ExecuteOrDelayUntilScriptLoaded(CustomAction, "sp.js");
...但这会引起毛球,上面刻有以下明显的暴躁表现:“未定义CustomAction ”
什么鬼,拉姆齐!我不能因为失败而获胜,正如那句老话。如何让 get_current() 始终正确执行?
所以,我尝试了这段代码:
function upsertPostTravelListItemTravelerInfo1() {
var clientContext = new SP.ClientContext(siteUrl);
. . .
...但是得到了这个错误消息:
Uncaught Sys.ArgumentException: Sys.ArgumentException: Value does not fall within the expected range.
Parameter name: serverRelativeUrl
随后出现了大量“gobbledygook”(只有纯 D 极客才会喜欢的转储),包括以下两个看起来可能有某种联系的部分:if(!SP.ScriptUtility.isUndefined(window._spPageContextInfo)&&!SP。 ScriptUtility.isUndefined(window._spFormDigestRefreshInterval)&&!SP.ScriptUtility.isUndefined(window.UpdateFormDigest)){var c=window._spPageContextInfo,d=c.webServerRelativeUrl,e=window._spFormDigestRefreshInterval;
...和:
if(!a)throw Error.argumentNull("serverRelativeUrl");if(!a.startsWith("/"))throw Error.argument("serverRelativeUrl");
任何人都可以对此做出正面或反面吗?