jquery - 找不到 jQuery

标签 jquery dynamics-crm-online dynamics-crm-2015

如图所示,我已将 jQuery 包添加到表单中。

enter image description here

这是具有最新界面的最新更新。

我如何收到以下错误消息。

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/

相关文章:

javascript - 不同页面的多次点击事件

javascript - 如果值为 true 则追加数据

dynamics-crm - 没有活跃的交易。此错误通常是由忽略服务调用错误并继续处理的自定义插件引起的

javascript - 将 html div 传递给 ajax 调用

javascript - 按下 Shift 键时防止 keyDown 事件

dynamics-crm-2011 - Microsoft CRM 2011 Online Fetchxml 加载到 CRM 时报告错误

javascript - 如何从控制台访问控件

c# - 如何使用 if 语句检查事件实体的状态代码?

dynamics-crm - 在单个 LINQ to CRM 查询中执行两个左外连接

dynamics-crm-2011 - 动态 CRM 2016 中电子邮件表单上的发件人字段锁定