JavaScript error when posting comments

May 11, 2010 at 7:31 AM
Hi all! One of my readers pointed out to me today that it is not possible to comment my blog posts om http://jonas.haksberg.net/ and he is correct. But, if I download the whole site and run it localy on my computer (you can test it here http://jonas.otio.se/bloge2/) then it works. The error I get is "'BlogEngine' is undefined' on row 458 in WebResource.axd and on row 1 in js.axd. Anyone know what this is about? Thanks in advance.
May 11, 2010 at 4:04 PM

Make sure you haven't removed a div tag you need on accident in the postview aspx file. I did this and spent 2 weeks figuring out what was causing comments not to work.

May 11, 2010 at 4:49 PM
Edited May 11, 2010 at 4:54 PM
Well, the strange thing is that it works locally, but not on my web host... Any ideas about that? EDIT: Ok, so I set up the blog locally on http://jonas.otio.se/ , that is without the bloge2/ subfolder, and it still works fine on my local computer.
May 11, 2010 at 4:54 PM

Are you in debug mode when doing it locally?


May 11, 2010 at 4:58 PM
Seems I was, debug argument for compilation tag in web.config was set to true. i will try setting it to false both online and localy.
May 11, 2010 at 5:01 PM
Well, that didn't make a difference... :(
May 17, 2010 at 6:59 AM

Is there no one that have experienced the same problem?

 

It might be something with my webhost maybe, since it works at home?

May 20, 2010 at 8:34 AM

For some mystical reason it stopped orking on my local computer too.

So I rewrite the comment posting part not to use AJAX, but postback instead.

May 22, 2010 at 8:55 PM
Edited May 22, 2010 at 9:12 PM

So, I've updated to 1.6.1.0, still the same problem, it is working locally but not on my webhost.

Also, the search functions isn't working either.

Is it seriously no one else who could help me out?

EDIT:
So, the problem seems to be in js.axd, on my webhost it returns nothing when trying to link in blog.js; http://jonas.haksberg.net/js.axd?path=/blog.js&v=1.6.1.0 but on my local-computer it works fine, and also comment posting and searching is working locally; http://jonas.otio.se/js.axd?path=/blog.js&v=1.6.1.0

Any ideas?

Coordinator
May 22, 2010 at 11:44 PM

First, is the blog.js file physically in the root folder?  If I try to navigate to:

http://jonas.haksberg.net/blog.js

It's a 404.

Second, assuming blog.js is there (somewhere), the first line in blog.js is:

// global object

Try removing (deleting) that line.  You may need to restart the blog for changes to take effect (because the contents of blog.js might be cached in memory).  You can restart the blog by making any change to the web.config file (add a space, etc).

May 23, 2010 at 7:58 AM

Thank you BenAmada!

Removing the först line with the comment in blog.js did the trick!

(Also I had ben fideling a bit last night and forgot to upload blog.js again that's why you couldn't see it, but it is there now).

But, I would like some sort of explanation to this, how come it doesn't work with the comment?

Thanks again!

Coordinator
May 23, 2010 at 9:44 AM

That's good news.  I'm not sure the exact reason why removing the first line works.  Some others in the past had the same problem, and removing the first line fixed it.

The first line is a JS comment -- it begins with two forward slashes.  One possible reason for the problem may be that when BE reads in that file, the built-in .NET functions that read the file are interpreting those two slashes as being some type of file "preamble" characters -- like BOM (byte order mark) characters -- rather than treating the two forward slashes as actual content.  And either it breaks there, or the two forward slashes get discarded (as they're considered not actual file content, but "header" info), and then the file ends up beginning with "global object" (without the two forward slashes) ... but this ends up with the JavaScript contents being invalid since you now have the file beginning with a syntax error.

This is just some ideas off the top of my head.  I haven't looked into it ... mostly because I'm not having this problem myself with blog.js ... so I can't easily reproduce it.

May 24, 2010 at 9:09 AM
All of those seem very plausible for me :) Anyway, thank you again.