making data available outside the doc.ready function
I am building an app using backbone....the backbone code is enclosed in the familiar document.ready function.
And the file where this code is located is imported(with the usual method in the header of a page) in a PHP script.
What I am trying to do is a variable that is inside the document.ready function,I want to make it available in the PHP script....an example will illustrate the case I think.
-
$(document).ready(function()
{
var john='45'
});
<?php
<div id="test">
document.write(john);
</script></div>
?>
-
<script type="text/javascript">
As you might guessed(from the description of the problem) the browser
does not print 45.
What can I do to solve this problem?