I met this issue sometimes but still don\'t know what causes it.
I have this script in the page:
$(function(){ var value = \"10\"; });
It's declared inside a closure, which means it can only be accessed there. If you want a variable accessible globally, you can remove the var:
var
$(function(){ value = "10"; }); value; // "10"
This is equivalent to writing window.value = "10";.
window.value = "10";