UI 宏中未定义 GlideAjax

GlideAjax is not defined in UI macro

我正在从 UI 宏调用 GlideAjax,但我遇到以下错误:

org.mozilla.javascript.EcmaError: "GlideAjax" is not defined.
Caused by error in at line 2

1:
==> 2: var ga = new GlideAjax('global.GetHostName');
3: ga.getXMLWait();
4: var hostName = ga.getAnswer();
5:

我的 UI 宏如下所示:

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate>
var ga = new GlideAjax('global.GetHostName');
ga.getXMLWait();
var hostName = ga.getAnswer(); 

</g:evaluate>
<!--<j:set var="jvar_inc" value="${help_sysid}" />-->
   <span id="asp-cms-user-salutation">
      ${gs.getMessage('Welcome')},
      <j:if test="${!gs.getUser().isXML()}">
         <span id="asp-cms-user-name"><a href="profile.do">${gs.getUserDisplayName()}</a></span>
<span id="asp-cms-user-sysname">${hostName}</span>
      </j:if>

   </span>


</j:jelly>

我哪里做错了??

GlideAjax 是客户端 api 用于让您的浏览器发出 ajax 请求。 jelly 中的 <g:evaluate> 标签是一个服务器端脚本。假设 GetHostName 是脚本包含名称,您可以直接调用脚本包含,如:

<g:evaluate>
var hostNameGetter = new global.GetHostName();
var hostName = hostNameGetter.getValue(); // replace getValue() with whatever your method name is in GetHostname
</g:evaluate>