Illegal character Javascript Error

Give me coffee and no one gets hurt.

Illegal character Javascript Error

Postby ShiftPoint » Fri Sep 25, 2009 7:55 am

I had a very interesting problem the other day. I am developing a web application in PHP however many of the components/extras are javascript. Particullary the datetime select (calendar). So every time you tried to call the javascript function to load the calendar it would throw an error stating that there was an "Illegal character" in the javascript file i was including on the page. It worked fine locally but when I pushed it (ftp) out to the production server it would throw the error.

So after googling for a few hours and not finding much I started to think about it. I decided to pull up the file in the browser to see how it rendered the file. Sure enough on the line that it was erroring was a bunch of junk data that looked something like this:


Error: illegal character
Source File: http://localhost/javascript/datetimepicker_css.js
Line: 9, Column: 12
Source Code:
var dtToday;਍瘀愀爀 䌀愀氀㬀ഀ

I remembered about a year ago I was using a plugin for cart systems (http://www.magic-seo-url.com/) and remembered that I had to upload one of the files in "Binary mode" rather than the default "ASCII" mode or you would get this type of thing.

So I fired up Filezilla, went to transfer -> transfer type and selected "Binary" rather than "Auto" and uploaded the file again. Then refreshed the browser that had the file pulled up and what do you know, it didn't have the junk data ;)

I checked the page with the javascript on it and it worked just like it did locally. Hope this helps!!!

Summary:
ftw = "BINARY MODE" :lol:
User avatar
ShiftPoint
 
Posts: 70
Joined: Sun Jul 05, 2009 4:52 pm
Location: Pickerington, OH

Return to J2EE

Who is online

Users browsing this forum: No registered users and 0 guests

cron