1

I've bumped into a weird problem. When I'm editing a .js document, I'm getting error "SyntaxError: illegal character".

Here is the part of the document. I've just added alert(1); as you can see:

Relevant Part of the Document

Here is how it shows in my browser (note that these symbols at the end of the document):

How It Shows in My Browser

About document: charset UTF-8, line breaks CRLF.

I'm using Firefox on Ubuntu. Headers from the local server:

Accept-Ranges: bytes
Connection: close
Content-Length: 56871
Content-Type: application/x-javascript
Date: Wed, 10 Feb 2016 15:15:05 GMT
Etag: "6d-de27-c52b5640"
Last-Modified: Wed, 10 Feb 2016 15:05:53 GMT
Server: Apache/2.2.3 (CentOS)

I tried to change Content-Type to application/javascript, tried to edit in different editors, tried to remove BOM -- the same result.

UPD: I don't know why but it works when I reload local server! (I use vagrant with centos installed). I tried to reload just apache - still error. UPD 2: mime-types for .js files on local server are text/x-c or text/x-c++ meanwhile it's text/plain on host machine

Alex K
  • 25
  • 7
  • Did you copy/paste some code into your JavaScript source, and do so from a web page? Sometimes that can cause stray Unicode invisible characters to be included. You can't see them, but the JavaScript parser does. – Pointy Feb 10 '16 at 15:25
  • Hi. Yes. I've copied 'alert' code from a web page. – Alex K Feb 10 '16 at 15:28
  • Well you may want to try deleting that and then typing it back in manually. – Pointy Feb 10 '16 at 15:29
  • Tried manual typing. The same result. – Alex K Feb 10 '16 at 15:30
  • It can be hard to get rid of those, but some editors make it easier than others. What line of code is associated with the syntax error? That's a good starting point. – Pointy Feb 10 '16 at 15:31
  • The last line is showed as containing error in developer's console. – Alex K Feb 10 '16 at 15:34
  • Right, well those little black things are probably what the problem is. – Pointy Feb 10 '16 at 15:49

2 Answers2

1

I've found the solution of the problem. I've added EnableSendfile Off to my .htaccess. For more information follow the link

Community
  • 1
  • 1
Alex K
  • 25
  • 7
0

put comma ',' after variable order_addresses And if you use ajax call to server do not use the Content type

Yasin Fatullayev
  • 137
  • 1
  • 11