最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Illegal Characters appended to javascript file - Stack Overflow

programmeradmin5浏览0评论

I think my apache webserver has got problem. I can't reference jquery.js

I get the following errors:

With chrome:

Uncaught SyntaxError: Unexpected token ILLEGAL

With firefox:

Error: illegal character
Source File: http://xxxxxxxxx/test/javascript/jquery.js
Line: 1
Source Code:
�Hz�ÚH[9�R

Below is my test html code

<html>
<head>
    <script type="text/javascript" src="javascript/jquery.js"></script>
    <script type="text/javascript">
        function doclick(){
            jQuery('#hello').attr('value', "mmmmef")
        }
    </script>
</head>
<body>
    <input type="button" name="hello" id="hello" value="hello" onclick="doclick();" />
</body>
</html>

It is not only happening to jquery.js, these illegal characters are being appended to all js and css files.

I login with ssh and view these js and css files with vi mand, but there are none of these characters. But when I try to download or view/edit with FTP clients Filezilla or CuteFTP, these illegal characters are included.

What's wrong with my server? The same code can run in my local windows server and another centos server.

I think my apache webserver has got problem. I can't reference jquery.js

I get the following errors:

With chrome:

Uncaught SyntaxError: Unexpected token ILLEGAL

With firefox:

Error: illegal character
Source File: http://xxxxxxxxx/test/javascript/jquery.js
Line: 1
Source Code:
�Hz�ÚH[9�R

Below is my test html code

<html>
<head>
    <script type="text/javascript" src="javascript/jquery.js"></script>
    <script type="text/javascript">
        function doclick(){
            jQuery('#hello').attr('value', "mmmmef")
        }
    </script>
</head>
<body>
    <input type="button" name="hello" id="hello" value="hello" onclick="doclick();" />
</body>
</html>

It is not only happening to jquery.js, these illegal characters are being appended to all js and css files.

I login with ssh and view these js and css files with vi mand, but there are none of these characters. But when I try to download or view/edit with FTP clients Filezilla or CuteFTP, these illegal characters are included.

What's wrong with my server? The same code can run in my local windows server and another centos server.

Share Improve this question edited Feb 20, 2013 at 20:13 Robert Harvey 181k48 gold badges348 silver badges512 bronze badges asked Mar 12, 2012 at 11:45 zawmn83zawmn83 8091 gold badge9 silver badges18 bronze badges 4
  • 2 Tell the real address, not xxxxxxxxx which does not exist and may be handled by browsers by appending ., resulting in a porn site address. We cannot see the internals, but with a URL, we could at least see the HTTP headers and could deduce which version of jquery is being used. – Jukka K. Korpela Commented Mar 12, 2012 at 12:04
  • The xxxxxxxx in url is IP address of my server. My server is in my internal network and I access via IP. e.g. 192.168.1.98/test. It is not related to jquery version, because at the top of all js and css files, these illegal chars are appended. – zawmn83 Commented Mar 13, 2012 at 4:36
  • There’s little hope of getting help with your server configuration if we cannot even see all the symptoms. Your description of Firefox behavior seems to say that garbage characters appear at the start of the .js file, and as its sole content, not appended. You really need to consult someone who can take a look inside the server. – Jukka K. Korpela Commented Mar 13, 2012 at 5:30
  • I note that when the reference files js/css with Content-Length less than 2654 byte are not error occur. When content length greater than or eqaul 2654, this illegal char error occur. – zawmn83 Commented Mar 13, 2012 at 5:34
Add a ment  | 

1 Answer 1

Reset to default 18

I found the solution at

http://www.cyberciti.biz/tips/apache-223-corrupt-file-download-issue.html

Just open httpd.conf and put below lines

            EnableMMAP off
            EnableSendfile off

then

            # /sbin/service httpd restart
发布评论

评论列表(0)

  1. 暂无评论