No callback on comment submit
|
albataur
Joined: 2011-01-04
Posts: 7 |
Posted: Tue, 2011-01-04 12:55
|
|
Hello ! I'm using gallery3. I have a problem when I try to add some comments. Nothing appends when I click on submit button (no errors, no confirm).
{"result":"error","form":"<form action=\"\/index.php\/comments\/create\/3830\" method=\"post\" id=\"g-comment-form\"><input type="hidden" name="g3sid" value=removed for public display />\n<input type=\"hidden\" name=\"csrf\" value=\"7d4358ea17a195d26e3c747eb0bfd3b9\" \/> <fieldset>\n <legend>Ajouter un commentaire<\/legend>\n <ul>\n <li class=\"g-error\">\n <label for=\"name\" >Nom<\/label>\n <input type=\"text\" id=\"g-author\" name=\"name\" value=\"\" class=\"textbox\" \/>\n <p class=\"g-message g-error\">\n Vous devez saisir votre nom\n <\/p>\n <\/li>\n <li class=\"g-error\">\n <label for=\"email\" >Email (cach\u00e9)<\/label>\n <input type=\"text\" id=\"g-email\" name=\"email\" value=\"\" class=\"textbox\" \/>\n <p class=\"g-message g-error\">\n Vous devez saisir une adresse email valide\n <\/p>\n <\/li>\n <li>\n <label for=\"url\" >Site web (cach\u00e9)<\/label>\n <input type=\"text\" id=\"g-url\" name=\"url\" value=\"\" class=\"textbox\" \/>\n <\/li>\n <li>\n <label for=\"text\" >Commentaire<\/label>\n <textarea id=\"g-text\" name=\"text\" rows=\"\" cols=\"\" class=\"textarea\" >fgdfg<\/textarea>\n <\/li>\n <li>\n <input type=\"submit\" value=\"Ajouter\" class=\"ui-state-default ui-corner-all\" \/>\n <\/li>\n <\/ul>\n <input type=\"hidden\" name=\"item_id\" value=\"3830\" \/>\n <\/fieldset>\n<\/form>"}I tried to add some alerts into the callback function, but it seems to be never called :
$("#g-comments form").ajaxForm({
dataType: "json",
success: function(data) {
alert('pouet1');
if (data.result == "success") {
$("#g-comments #g-comment-detail ul").append(data.view);
$("#g-comments #g-comment-detail ul li:last").effect("highlight", {color: "#cfc"}, 8000);
$("#g-comment-form").hide(2000).remove();
$("#g-no-comments").hide(2000);
} else {
alert('pouet');
if (data.form) {
$("#g-comments form").replaceWith(data.form);
ajaxify_comment_form();
}
}
}
});
I don't know JQuery so it's difficult for me to debug this. You can look at this on http://photos.alexis-bataille.com/index.php/Photos-Etretat-2010/P1030589 . Thanks ! |
|

Posts: 7
I think I'm not the only one to have this problem : http://gallery.menalto.com/node/100032
Posts: 7
No idea ?
Posts: 7
Ok I think I found why callback isn't called.
JSON response is incorrect. It's missing some backslashes before " :
{
"result":"error",
"form":"<form action=\"\/index.php\/comments\/create\/3830\" method=\"post\" id=\"g-comment-form\"><input type="hidden" name="g3sid" value=removed for public display />\n<input type=\"hidden\" ...
}
I'll try to found where I can correct it.
Posts: 7
I browsed almost every files for finding where is added this field ... unsuccessful.
Must I add a bug in the bug tracker ?
Posts: 7994
Ah, you're getting bitten by this: https://sourceforge.net/apps/trac/gallery/ticket/1316
This is a very bad PHP setting, it silently munges the HTML that we generate. I've added a fix in 3.0.1 to warn admins when this setting is on, but in the meantime turn it off and you'll be fine.
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!
Posts: 7
Wow indeed, it was this ! Thank you !
I understand why I spent so long time for finding in the code where it was added ... unsuccessful.
Nevertheless, I tried to put this setting off in htaccess :
But it didn't work (gallery is on a shared host). Any idea ?
Finally I setted it in index.php
Anyway, thank you for your help !
Posts: 7994
@albataur: I have committed your suggested fix to 3.0.1 -- thanks!
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!