Josh, thanks for your response - it helped clear up some of my
problems when I moved the var thisStory = $.getJSON("javascript/
test.js", function(json){etc.}); out of the $(document).ready();
block. Now at least the document.write is executing on the page...

But it's being written out as "undefined by undefined" which means
that the values in the test.js still aren't available outside of the
var thisStory = $.getJSON() script (a (not) working full html file is
available at :

        <script type="text/javascript">  //<![CDATA[
                var thisStory = $.getJSON("javascript/test.js", function(json){
                                                                    
alert("title: " + json.title + '\n'+
                                                                          
"author: " + json.author + '\n' +
                                                                           
"frame3 : " + json.frames.frame3 + ' ' +
json.texts.frame3  + '\n' +
                                                                           
"imgurl: " + json.imgURL +  '\n');
                                                                                
   return json;
                                                                });
        //]]></script>

[later in the body]

        <script type="text/javascript">  //<![CDATA[
                                document.write('<i>' + thisStory.title + '</i>' 
+ ' by ' +
thisStory.author + '<br><br>');
        //]]></script>

In other words, that alert() function is working fine. But the
document.write isn't getting the value of thisStory.title, for
example.

Is this a problem with scope? I tried returning json at the end of the
getJson bit thinking maybe thisStory = $.getJSON("javascript/test.js")
wasn't enough to load the values from the test.js file into the
thisStory object.  Am I missing something fundamental here?  I feel
like I am, but as I've mentioned I can't tell exactly what. The same
code works great if the JSON object is in the HTML file, so I feel
like this is a weird thing associated with JSON somehow.

Thanks for any insight or clarification!

Reply via email to