I have a javascript function that makes an ajax get request. This is a legacy application and I am limited to what I can do . I cannot use jquery.
As you can see I am using scriptlet to access object in request scope. I am trying to alert the value returned by the scriptlet but I keep getting
Uncaught ReferenceError: google is not defined
"google" is the value returned by the scriptlet which is the expected/correct value.
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);
}
As you can see in the image below of my debugging console, the value inside the alert() correctly evaluates to "google.com"
You are attempting to alert a string, but your code thinks its a variable, thus getting the "not defined" error. You need to surround your answer with quotes:
alert("google.com");