when user inserts words with single qoute it shows jquery error, for example if i insert worlds with single quote ike That's mind, it will show error becuase of the single qoute, how do i correct that.
<div class="modal fade" id="myModalsharepost12" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button><h4 class="modal-title" id="H2">post text </h4></div><div id="modalbodyt" class="modal-body">
<div class="tblCustomer">
<div>
<span class="pull-left " style="margin-right: 8px">
<asp:Image ID="Imageuser8" runat="server" src='<%#Eval("ImageName")%>'
class="imageuser8 media-object img-circle animated fadeInDown" Style="width: 45px; height: 45px;" />
<span class="clearfix"></span>
</span>
<div class="pull-left " style="">
<div class="clearfix">
</div>
</div>
<div class="pull-left " style="">
<span class="name" style="font-family: Arial, Helvetica, sans-serif; font-weight: bold">
<%# Eval("Name") %></span>
<span class="username">
<%# Eval("UserName") %>
</span>
<div class="clearfix">
</div>
<span class="senddate5" style="font-family: Arial, Helvetica, sans-serif; font-weight: bold">
<%# Eval("SendDate") %>
</span>
<div class="clearfix">
</div>
</div>
<div class=" " style="">
</div>
<div class="clearfix">
</div>
<div class="" style="margin-bottom: 4px">
</div>
<span class="contentpost" style="font-family: Arial, Helvetica, sans-serif; font-weight: normal">
<%# Eval("ContentPost") %>
</span>
<br />
<div class="clearfix">
</div>
<span></span>
<span class="id" style="font-size: 0; color: #FFFFFF">
<%# Eval("ID") %></span>
<a>
<span class="imagename15" style="font-size: large">
<%# Eval("ImageName1") %>
</span>
</a>
<span class="path" style="font-size: large">
<%# Eval("Path") %>
</span>
</div>
</div>
</div>
<div class="modal-header" style="background-color: #E8F5FD">
<textarea name="TXTcommentsSHARE" rows="4" cols="20" id="TXTcommentsSHARE" class=" form-control"
placeholder="Comment" maxlength="500"></textarea> <div class=" pull-right" style="">
<asp:Label ID="lblcommentslimit" runat="server" Text=""></asp:Label></div><div class="clearfix"></div>
<div class="" style="margin-bottom: 6px"></div>
</div>
<div class="modal-footer">
<asp:LinkButton ID="btnSHpst" runat="server" CssClass="btn btn-info " BorderStyle="Solid"
BorderWidth="1" BorderColor="#007ACC">
<div class="">
<span class="" style="">
<asp:Label ID="Label26" runat="server" Text="" CssClass=""
Font-Bold="True" Font-Size="Large"></asp:Label>
</span><span>
<asp:Label ID="Label40" runat="server" Text="post" Font-Bold="True" Font-Size="Large"></asp:Label>
</span>
</div>
</asp:LinkButton></div></div></div></div>
<script type="text/javascript">
$(function () {
$('[id*=btnonpst]').on('click', function () {
var id = $(this).closest('tr').find($('[id*=ProdID]')).text();
$('[id*=myModalsharepost12]').modal('show');
$.ajax({
type: "POST",
url: "/HomePage.aspx/GetNameUserName5",
data: '{id:"' + id + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
// clear old value
$(".id").html('');
$(".imageuser8").attr('src', '');
$(".username").html('');
$(".name").html('');
$(".senddate5").html('');
$(".contentpost").html('');
$(".imagename15").html('');
$(".path").html('');
// Assign new value
if (response.d.length > 0) {
$(".id").html(response.d[0].Id);
$(".imageuser8").attr('src', '/PROFILEPHOTOS/' + response.d[0].Imageuser7);
$(".username").html(response.d[0].UserName);
$(".name").html(response.d[0].Name);
$(".senddate5").html(response.d[0].SendDate);
$(".contentpost").html(response.d[0].ContentPost);
$(".imagename15").html(response.d[0].imagename15);
$(".path").html(response.d[0].path);
}
},
});
return false;
});
$('[id*=btnSHpst]').click(function () {
// var id = "1";
var id = $('.id').html().trim();
var name = $('.name').html().trim();
var username = $('.username').html().trim();
var contentPost = $('.contentpost').html().trim();
var senddate5 = $('.senddate5').html().trim();
var imagename15 = $('.imagename15').html().trim();
var path = $('.path').html().trim();
// If you ant to insert "PROFILEPHOTOS/Test.jpg" format then use the below line
var imageuser8 = $('.imageuser8').attr('src').slice(($('.imageuser8').attr('src').lastIndexOf('/') + 1), $('.imageuser8').attr('src').length);
//If you ant to insert "Test.jpg" format then use the below line
var TXTcomments = $("#TXTcommentsSHARE").val();
$.ajax({
type: "POST",
url: "/HomePage.aspx/InsertPostASHAREpst9",
data: "{id:'" + id + "',name:'" + name + "',username:'" + username + "',contentpost:'" + contentPost + "',TXTcomments:'" + TXTcomments + "',senddate5:'" + senddate5 + "',imagename15:'" + imagename15 + "',path:'" + path + "',imageuser8:'" + imageuser8 + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$('#myModalsharepost12').modal('hide');
$("#lblText").html('Post Shared Successfully.');
$('#dialog1').fadeIn('slow').delay(1000).fadeOut('slow');
window.location.reload();
// clear value
$(".id").html('');
$(".imageuser8").attr('src', '');
$(".username").html('');
$(".name").html('');
$(".senddate5").html('');
$(".contentpost").html('');
$(".imagename15").html('');
$(".path").html('');
},
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
return false;
});
});
</script>