GlidAjax未在UI宏中定义

时间:2017-06-23 14:06:09

标签: macros servicenow jelly

我从UI Macro调用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>

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

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>