- Miscellany
- Monday, August 13th, 2007 at 2:52:09pm MDT
- function submit_comment() {
- if ($('id_question') && $('id_question').value !=$('id_answer').value) {
- alert("Sorry, you answered the question incorrectly.");
- return false;
- }
- for (var e=this.parentNode;e.tagName!='FORM';e=e.parentNode) {}
- var form_contents = formContents(e);
- var content=queryString(form_contents[0], form_contents[1]);
- var d = doXHR("/comments/post/?xhr", { method: "POST",
- mimeType : 'application/x-www-form-urlencoded',
- sendContent : content,
- headers : { 'Content-Type' :
- 'application/x-www-form-urlencoded'}
- });
- var gotData = function (xhr) {
- var z;
- var data = evalJSONRequest(xhr);
- if (data['errors']) {
- new_errors = DIV({'id':'errors'}, null);
- for (k in data['errors']) {
- appendChildNodes(new_errors, P(null, 'Error in '+k+': '+data['errors'][k]));
- }
- swapDOM($('errors'), new_errors);
- return;
- }
- var toggle = false;
- tbody=TBODY(null, null);
- for (var i=0;i<data.length;i++) {
- z = TR( {'class': (toggle ? 'odd':'even')}, TH({'valign':'top'}, data[i]['username']+' said:'), TD(null, data[i]['text']));
- appendChildNodes(tbody, z);
- toggle = !toggle;
- }
- var newTable = TABLE({'cellpadding':"0", 'cellspacing':"0", 'class':"comments", 'id':"comments-list"}, tbody);
- swapDOM($('comments-list'), newTable);
- };
- var dataFetchFailed = function (err) {
- alert("ajax error");
- };
- d.addCallbacks(gotData, dataFetchFailed);
- return false;
- }
- function setup_comments() {
- var submit_buttons = $$('input.submit');
- for (var i=0;i<submit_buttons.length;i++) {
- submit_buttons[i].onclick=submit_comment;
- }
- }
- addLoadEvent(setup_comments);
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.