Javascript-Problems saving a comment

Topics: Controls, Themes
Feb 3, 2008 at 2:34 PM
I am running a blog under http://design.speak-friend.com.
Whenever someone tries to press the "submit-comment"-button after writing a comment, a rotating circle appears and the text "Saving the comment". However, nothing else happens. Thus the user thinks, the comment is not being saved.
However, the comment actually is being saved.
Intend is, that there appears a line (after saving the comment) which says: "Thank you for posting a comment".

I have uploaded a screenshot of the firebug-error under: http://design.speak-friend.com/debugging.jpg

The javascript is this (at least I suppose) from UserControls/CommentView.ascx:

<script type="text/javascript">
<!--//
var isAjaxSupported = (window.ActiveXObject != "undefined" || window.XMLHttpRequest != "undefined");
if (!isAjaxSupported)
{
document.getElementById('<%=btnSave.ClientID %>').style.display = "inline";
document.getElementById('btnSave').style.display = "none";
}

function AddComment()
{
document.getElementById("btnSave").disabled = true;
document.getElementById("ajaxLoader").style.display = "inline";
document.getElementById("status").className = "";
document.getElementById("status").innerHTML = "Saving the comment...";

var author = document.getElementById("<%=txtName.ClientID %>").value;
var email = document.getElementById("<%=txtEmail.ClientID %>").value;
var website = document.getElementById("<%=txtWebsite.ClientID %>").value;
var country = "";
if (document.getElementById("<%=ddlCountry.ClientID %>"))
country = document.getElementById("<%=ddlCountry.ClientID %>").value;
var content = document.getElementById("<%=txtContent.ClientID %>").value;
var notify = document.getElementById("cbNotify").checked;
var argument = author + "-|-" + email + "-|-" + website + "-|-" + country + "-|-" + content + "-|-" + notify;
<%=Page.ClientScript.GetCallbackEventReference(this, "argument", "AppendComment", "'comment'") %>

if (typeof OnComment != "undefined")
OnComment(author, email, website, country, content);
}

function AppendComment(args, context)
{
if (context == "comment")
{
if (document.getElementById("commentlist").innerHTML == "")
document.getElementById("commentlist").innerHTML = "<h1 id='comment'>Comments</h1>"
document.getElementById("commentlist").innerHTML += args;
document.getElementById("<%=txtContent.ClientID %>").value = "";
document.getElementById("ajaxLoader").style.display = "none";
document.getElementById("status").className = "success";
document.getElementById("status").innerHTML = "<%=Resources.labels.commentWasSaved %>";
}

document.getElementById("btnSave").disabled = false;
}

var flagImage = document.getElementById("<%= imgFlag.ClientID %>");

function SetFlag(iso)
{
if (iso.length > 0)
flagImage.src = "<%=VirtualPathUtility.ToAbsolute("~/") %>pics/flags/" + iso + ".png";
else
flagImage.src = "<%=VirtualPathUtility.ToAbsolute("~/") %>pics/pixel.gif";
}

function CheckAuthorName(sender, args)
{
args.IsValid = true;

<% if (!Page.User.Identity.IsAuthenticated){ %>
var author = "<%=Post.Author %>";
var visitor = document.getElementById("<%=txtName.ClientID %>").value;
args.IsValid = author.toLowerCase() != visitor.toLowerCase();
<%} %>
}
//-->
</script>

Any help or suggestions would be greately appreciated.

Andrej
Feb 16, 2008 at 2:36 PM
Andrej,

I have the exact same issue: everything else is working (adding, editing posts), except for saving comments which gives me the Saving Comment message as well. Have you managed to fix this?
Feb 16, 2008 at 2:38 PM
Hmm, I just see it works fine under IE7, but it is not working under Firefox 2...
Feb 16, 2008 at 2:47 PM
Weird stuff... All of a sudden it started working as well on Firefox, without me making any changes.
Coordinator
Feb 16, 2008 at 3:14 PM

TomvE wrote:
Weird stuff... All of a sudden it started working as well on Firefox, without me making any changes.

I had FF crashing badly on ajax-enabled sites, turned out had to disable firebug add-on while browsing web. In your case, may be something changed on the FF side...
Feb 16, 2008 at 3:38 PM
Hey TomvE

The point is: The javascript looks for "commentlist" and if it is empty it does not find it. As soon as there is a comment on your article, the "commentlist" is not empty, thus found, thus no problems.

As I said, it gives you only problems for the first comment.

And no, I have not found a solution...
Apr 18, 2008 at 1:13 PM
Did anyone find a solution to this? I have the same problem.
Jun 11, 2008 at 9:01 PM
I'm also experiencing this problem on one of my Blog Engine sites.  Has anyone figured this out?  Thank you.

Aaron
Jun 13, 2008 at 12:02 PM
This is causing serious problems for me... nobody can make comments to my blog! Same exact issue as described above. Please fix!
Jun 21, 2008 at 11:30 PM
Edited Jun 21, 2008 at 11:34 PM
I don't know if I should post this as a separate discussion or not. I experienced the same problem this week trying to get my fresh installation of BlogEngine 1.3.1 working on my web host.

Note: I have located it in a sub-folder off the main root of the site, i.e. "www.mysite.com/mike/blog/". App_Data folder permissions have been set up correctly - I can create new posts. However, although comments could be saved fine on my local laptop IIS install, when deployed to the web host, I'd get script errors:
  • "isAjaxSupported is not defined" as the page loads
  • "$ is not defined" when the cursor left the NAME text box
  • "ShowCommentPreview is not defined" when the cursor enters the comment text area.
I couldn't see these errors until I opened Firefox's Error Console.

After some poking around, I decided it was as though the blog.js script file wasn't being found and attached to the post page. Looking at the source of the page, I did see the following at the end of the HEAD tag:

<script type="text/javascript" src="/mike/blog/js.axd?path=%2fmike%2fblog%2fblog.js"></script><title>Title of Post</title></head>

That looks as though it should be including the blog.js OK... but the errors sure seemed to indicate that the script file just wasn't being seen at all!

As a HACK to see if it would change anything, I altered my theme's site.master file thusly:

<head runat="server" profile="http://gmpg.org/xfn/11">
    <link rel="stylesheet" href="default.css" type="text/css" />
    <link rel="shortcut icon" href="~/pics/favicon.ico" type="image/x-icon"/>
    <script type="text/javascript" src="/mike/blog/blog.js"></script>
</head>

In other words, I hard-coded the link to the script file into the .master, and re-uploaded the site.master file to my host server. Comments can now be saved, and I no longer see the errors in the Error Console window.

Why isn't the programatically added script link working? Where should I look next in order to fix this?
Jun 26, 2008 at 9:45 PM
I was having this problem until I got the 1.3.1.39 release. (I think that was the fix)  I think rtur fixed it.

There was an update in the comments control and in the .css file that fixed the 'saving comment' pic from staying there after the comment was saved.

rclarkson also fixed another comment related error in release, that I saw, on June 22, 2008 labeled minor fixes.  There was a problem with the raisecallback event that was happening if you had your blog in a folder other than the root of your website.
Jul 24, 2008 at 1:49 AM
Adding the blog.js file also worked for me.