如图所示,我已将 jQuery 包添加到表单中。
这是具有最新界面的最新更新。
我如何收到以下错误消息。
ReferenceError: '$' is undefined at temp (https://xxxx.crm4.dynamics.com/%7B635678213980001086%7D/WebResources/xxxx_Temp.js?ver=1543403284:4:5)
不起作用的“代码”是这个。
function temp() { $.ajax({...}); }
请注意,实际呈现 HTML 的代码并不是作为可在 CRM 中编辑的源代码完成的。
我尝试通过控制台访问它,它似乎可以工作,但我是初学者,我迷路了。不确定要在 Google 上搜索哪些关键字。
最佳答案
您依赖于第三方 JQuery 文件,这可能是您的问题。我不确定,但 Microsoft 可能会在该库中执行 .noConflict()
,这样 $
就不是对 JQuery 的引用。
Microsoft's documentation特别建议不要在表单事件中使用 JQuery。
We do not recommend using jQuery in form scripts and ribbon commands. Most of the benefit provided by jQuery is that it allows for easy cross-browser manipulation of the DOM. This is explicitly unsupported within form scripts and ribbon commands. Restrict your scripts to use the Xrm.Page and Xrm.Utility libraries available in form scripts and ribbon commands.
您不需要使用$.ajax()
:
Using $.ajax to perform requests against the OData and Modern Apps SOAP endpoint is supported, but there are alternatives. The alternative to using $.ajax is to use the browsers XMLHttpRequest object directly. The jQuery $.ajax method is just a wrapper for this object. If you use the native XMLHttpRequest object directly, you do not need to load jQuery.
如果您想避免所有故障排除,请使用已经解决了这些问题甚至更多问题的可靠解决方案。我建议查看XrmServiceToolkit其中包括自己的 JQuery 副本,并针对 Dynamics CRM 2015 进行了全面测试。
无论如何,您当然不应该依赖事件源解决方案中的 JQuery 库。
关于jquery - 找不到 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30379444/