now fixed the comment posting functionality for ngx_openresty :D

This commit is contained in:
agentzh (章亦春) 2010-02-09 18:38:23 +08:00
parent c5a7c04b77
commit dd1d50c2fe
1 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,5 @@
var account = 'agentzh'; var account = 'agentzh';
//var host = 'http://10.32.24.13:1984';
var host = 'http://localhost:1984'; var host = 'http://localhost:1984';
//var host = 'http://api.eeeeworks.org'; //var host = 'http://api.eeeeworks.org';
//var host = 'http://api.openresty.org'; //var host = 'http://api.openresty.org';
@ -487,14 +488,15 @@ function postComment (form) {
//openresty.purge(); //openresty.purge();
setStatus(true, 'afterPostComment'); setStatus(true, 'afterPostComment');
openresty.callback = afterPostComment; openresty.callback = afterPostComment;
openresty.formId = 'comment-form'; //openresty.formId = 'comment-form';
openresty.post('/=/action/NewComment/~/~', data); // TODO openresty.post('/=/batch/NewComment/~/~', data);
openresty.get('/=/batch/NewComment/~/~', data);
return false; return false;
} }
function afterPostComment (res) { function afterPostComment (res) {
setStatus(false, 'afterPostComment'); setStatus(false, 'afterPostComment');
//alert("HERE!!!"); //alert("HERE!!! afterPostComment");
if (!openresty.isSuccess(res)) { if (!openresty.isSuccess(res)) {
error("Failed to post the comment: " + res.errstr); error("Failed to post the comment: " + res.errstr);
} else { } else {
@ -505,9 +507,7 @@ function afterPostComment (res) {
var postId = spans.attr('post'); var postId = spans.attr('post');
//debug(JSON.stringify(res)); //debug(JSON.stringify(res));
var commentId; var commentId = res[0].insert_id;
var match = res[0].last_row.match(/\d+$/);
if (match.length) commentId = match[0];
location.hash = 'post-' + postId + ':' + location.hash = 'post-' + postId + ':' +
(commentId ? 'comment-' + commentId : 'comments'); (commentId ? 'comment-' + commentId : 'comments');
spans.text(commentCount + 1); spans.text(commentCount + 1);