开发者

Javascript .js loading issue

开发者 https://www.devze.com 2023-01-10 10:41 出处:网络
I am editing an existing site, which is a typical merchant site. A series of PHP files with one main index that loads in the various content pages.

I am editing an existing site, which is a typical merchant site. A series of PHP files with one main index that loads in the various content pages.

The main index.php, u开发者_运维知识库sing <script>, loads in jsFunctions.js.

When ever I modify the jsFunctions.js file, the index only loads the jsFunctions.js partially. For example I will get a firebug error such as 'unterminated string literal' or 'missing end }' or similar. The errors themselves make sense, because the js file isn't fully loading, a brace or quote is missing and throwing an error. It is seemingly random, sometimes it will load 100 lines of the js, then sometimes 105 lines, etc.

But why would the file be partially loading if i edit it? If i remove the single line of my code, no matter how simple, it starts working again?

Any ideas?


Are you editing a file with inconsistent line-endings, which editor? Issues like line-ending or weird unicode characters cause the issues like you've described.

I would take the contents of the file after your edit do a copy/paste exact as it is to JSLint: http://www.jslint.com/

JSLint is a validation tool for your script, before checking for best practices though, it'll check that your script is valid at all. See if you get the same error, it could be a weird character that's slipped in there causing issues, JSLint will alert you to this and where it's at.


Apparently it was some kind of server serving issue. If I refreshed a random amount of times, the full js would load. Once loaded it works 100% after that, well until I uploaded a new copy, then I would have to refresh a couple of times (or possibly wait 1-2 mins).

Filezilla was showing that the upload was complete, but the server simply didn't seem ready to output it.

Thanks guys

0

精彩评论

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