views:

171

answers:

1

Hi All,

I'm hoping someone can help me with this as I'm at a loss. I'm trying to simply load a plain text file into a page at runtime using jquery- everything works fine in IE8 (8.0.7600.16385), Firefox 3.6.3, however in Google Chrome 5.0.375.55 the "data" comes back as nothing- i get an empty alert box.

This is the code i'm using;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <title>Animation Test</title>
    <script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $.ajax({
                url: 'level1.txt',
                success: function (data) {
                    alert(data);
                },
                async: true,
                type: 'GET'
            });
        });
</script> 
</head>
<body>
    <canvas id="canvas" width="640" height="480">
        Unsupported Browser
    </canvas>

</body>
</html>

The file I'm loading in is a plain text file containing this;

Central Cavern
100
O.........1.C....C...........1.O
O................1.............O
O..............................O
O..............................O
O......................B1..B...O
O=============~~~~=~~~~========O
O.............................1O
O===...........................O
O............A..OOO.B..........O
O====...<<<<<<<<<<<<<<<<<<<<...O
O............................==O
O..............................O
O..........B........OOO.....===O
O....===============...........O
O%............................XO
O==============================O

(Yes- it's the first level from Manic Miner! I'm making a javascript version using the html5 canvas to get my head around using it.)

I'm at a total loss- it can't be the code because it runs in the other 2 browsers- is there an issue with jquery and this version of Chrome?

Thanks for reading!!

Shaw.

+6  A: 

Are you running this locally, or on a web server? If you are running locally, then yes, Chrome will have this problem. See this question for solutions.

The Chrome issue is detailed here.

I start Chrome with this command line option to get around the problem: --allow-file-access-from-files.

Tauren
Haha- yes- hours i've spent on this over the afternoon- thats exactly what it is- works fine from a hosted environment; http://8weekgame.shawson.co.uk/shaw-demos/chrome-text-load-test.htmthanks a lot for the prompt response!!
Shawson