【发布时间】:2016-01-02 13:39:16
【问题描述】:
我有一个发出 ajax 获取请求的 javascript 函数。这是一个遗留应用程序,我只能做我能做的事情。我不能使用 jquery。
如您所见,我正在使用 scriptlet 访问请求范围内的对象。我正在尝试提醒 scriptlet 返回的值,但我不断收到
Uncaught ReferenceError: google is not defined
“google”是脚本返回的值,它是预期/正确的值。
function getLinkAddress(linkClicked){
httpGetUrl("http://www.google.com");
alert(<%=((DynaActionForm) request.getAttribute("ipacForm")).get("url").toString() %>);
}
function httpGetUrl(theUrl){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "?screenName=LinkAddress&buttonName=get", false);
xmlHttp.send(null);
}
正如您在我的调试控制台下图中所见,alert() 中的值正确评估为“google.com”
【问题讨论】:
-
你忘记了引号。它是一个字符串而不是一个变量。
标签: javascript java jsp web-applications scriptlet