function RejectItem(link, compqID, comments, officerID) {
if ($(link).parent().find("div.divComments").is(":visible")) {
$.ajax({
type: "POST",
url: "../contentService.asmx/RejectComplianceItem",
data: "{ 'compqID': '" + compqID + "', 'comments': '" + $(link).parent().find("div.divComments").find('.taComments').val() + "', 'officerID': '" + officerID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
hideRow(compqID);
}
});
} else {
$(link).parent().find("div.divComments").show();
}
}
Whenever ($(link).parent().find("div.divComments").find('.taComments').val()) returns a value that has single quote in this function, it fails.
Any fix?
Do you want to encode the data you send as JSON? If so, then your JSON is not valid anyway. Strings and keys must be enclosed in double quotes.
Use
JSON.stringify[docs]:The
JSONimplementation is also available here.