Mercurial > hg > chronicle
view themes/blog.steve.org.uk/ajax.js @ 155:4d2f0d6866e5
Updated the display of the blog comment when using AJAX
author | Steve Kemp <steve@steve.org.uk> |
---|---|
date | Thu, 03 Jan 2008 21:45:58 +0000 |
parents | 4a882ba147e4 |
children | 8b0c547cd015 |
line wrap: on
line source
function submitAjax() { var xhr; try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e2) { try { xhr = new XMLHttpRequest(); } catch (e3) { xhr = false; } } } xhr.onreadystatechange = function() { if(xhr.readyState == 4) { if(xhr.status == 200) { var o = document.getElementById( "output" ); o.innerHTML = xhr.responseText; } else { var o = document.getElementById( "output" ); o.innerHTML = "Failed HTTP code " + xhr.status + " " + xhr.responseText; } } }; data = 'ajax=1'; data = data + '&id=' + escape(document.forms[0].id.value ); data = data + '&captcha=' + escape( document.forms[0].captcha.value ); data = data + '&id=' + escape(document.forms[0].id.value ); data = data + '&captcha=' + escape( document.forms[0].captcha.value ); data = data + '&name=' + escape( document.forms[0].name.value ); data = data + '&mail=' + escape( document.forms[0].mail.value ); data = data + '&body=' + escape( document.forms[0].body.value ); xhr.open("POST", "/cgi-bin/comments.cgi", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(data); }