Illegal Characters appended to javascript file

对着背影说爱祢 提交于 2020-01-01 04:54:08

问题


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 command, 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.


回答1:


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


来源:https://stackoverflow.com/questions/9666416/illegal-characters-appended-to-javascript-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!