I just want to be able to access variable userid in document.ready
function. It's accessible in the JSP page but not in jQuery. I am able to print value of ${userid}
on the same JSP page but not in jQuery. I have passed userid
obj with model and view object to this JSP page. However I am not able to access that object.
$(document).ready(function(){
var examid = ${userid};
alert("Hello !");
//alert(username);
});
If the value of ${userid} is a string then you need to wrap it in quotes, otherwise you'll be getting a syntax error thrown in your JS code. For example var examid = '${userid}';
– Rory McCrossan Apr 4 at 10:45