If I post a comment like "hello there dog" it works great, but if there are any special characters like ' or " the comment is posted successfully to the database but the jQuery code is not displaying the comment in the list.
Thanks for any tips.
function feedbacksubmit () {
// Show the Ajax Loader
$("#ajaxloader").css("display","inline");
var textsubmitted = $("#feedbackinput").val();
if (textsubmitted.length < 5) {
alert("Don't forget to write something!");
// Hide the Ajax Loader
$("#ajaxloader").css("display","none");
}
else {
$.post("/feedback/ajax/insert/", {feedback: textsubmitted},
function(data) {
// Place the comment in the top of the list
$('<li></li>').prependTo("#comment-list").hide().prepend(data.commenttext2insert).fadeIn('slow');
// Hide the Ajax Loader
$("#ajaxloader").css("display","none");
// Clear out the textarea
$("#feedbackinput").val('');
}, "json");
}
}
Here is an example response that is not working with the jQuery code above:
{"returnmessage":"The Ajax operation was successful.","returncode":"0","commenttext2insert":"\n\t<div class=\"comment-header\">\n\t\t<span class=\"comment-avatar\">\n\t\t\t<a href=\"\">\n\t\t\t\t\n\t\t\t\t\t<img src=\"/_images/users/photos//17941/nobosh.jpg\" />\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t</a>\n\t\t</span>\n\t\t<span class=\"comment-author\">\n\t\t\t<a href=\"\">\n\t\t\t\t<b>BOB Man</b>\n\t\t\t</a>\n\t\t</span>\n\t\t<span class=\"comment-timestamp\">just now</span>\n\t</div>\n\t<div class=\"comment-body\">\n\t\t<p>12wsa\'</p>\n\t</div>\n"}