开发者

Jquery/JS not loading text file

I am writing a word/name generator. On my local computer the script works fine but when uploaded, the jQuery is not able to load the text file and I get a 404 not found error. The text file is there, I have checked a number of times. Here is the simplified code: http://namepicker.site11.com/test.html

Thank you for any advise, Todd

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>JQuery-Load Text File</title>
        <script type="text/javascript" src="./js/jquery-1.4.3.min.js"></script>
            <script type="text/javascript">
            function loadXML()
 开发者_如何学Go           {
                var file= './names/names.txt';
                $.get(file, function(data) {
                    alert(data);
                });
            }
            </script>
    </head>

    <body onload="loadXML();">
    </body>
</html>


Well a simple look at Chrome's Developer Tools reveals this error:

GET http://namepicker.site11.com/names/names.txt 404 (Not Found)

Obviously, you'd need to actually upload the names.txt file into the names directory.

Edit: I see that other files redirect to your hosting 404 page while names/names.txt does not, so perhaps it exists but does it somehow still send a 404 code. Is it a real text file or an underlying PHP file?


http://namepicker.site11.com/names/names.txt

The file does not exist, It needs to be there to be loaded. Try creating it and see if your having the same issues.

EDIT: http://namepicker.site11.com/names/

File does seem to exist, perhaps check the CHMOD settings on the files.


jQuery is not ready yet. You need to wrap jQuery functions.

For example:

$(function() {
    $(window).load(function()
        var file= './names/names.txt';
        $.get(file, function(data) {
            alert(data);
        });
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜