I have came across a question when I am doing Intersystem Cache Server Page with Javascript.
Here is my Sample Code:
Case 1:
<script language="Javascript">
function test1(){
var val = 0;
#server(..Set())#;
alert(val);
}
</script>
<script language="Cache" method="Set">
Write "val = 50;"
</script>
In this case, when the function test1() is called, the value = 0 and it is a local variable.
Case 2:
<script language="Javascript">
function test1(){
#server(..Set())#;
alert(val);
}
</script>
<script language="Cache" method="Set">
Write "val = 50;"
</script>
In this case, when the function test1() is called, the val = 50 and value is now a global variable.
So my questions are:
- How can I successfully set a value in Case 1 through Cache Server Method?
- Why Cache Server Method can declare a global variable in Javascript but not able to set a value to a variable?
You can't just generate javascript code on server side this way. You can return one value from this method and get it back in Javascript.