I am trying to update data using jquery but it fails in case of textarea having enter in it, which is represented by \r\n in mysql.
my code for update function is.
<td><i class="fa fa-edit" onclick="upd('<?php echo $fetch_news ['title']; ?>',
'<?php echo $fetch_news ['detail']; ?>',
'<?php echo $fetch_news ['date']; ?>',
'<?php echo $fetch_news ['id']; ?>'
)"></i></td>
and my update function is
function upd(title,detail,date,id)
{
$("#newsTitle").val(title);
$("#newsDetails").val(detail);
$("#newsDate").val(date);
$("#id").val(id);
}
my text area input is
<div class="form-group"><textarea id="newsDetails" name="newsDetails" title="News Location (less than 200 words)" placeholder="News Details (less than 200 words)" required="" class="form-control"></textarea></div>
this code works fine if there is no enter pressed while inserting textarea data
the error i get is
Uncaught SyntaxError: Invalid or unexpected token
my insert function is
$(function () {
$("#form").on("submit", function(){
$.ajax({
url: "extra/logical.php?pg=news&tsk=ins",
type: 'POST',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(data) {
$("#showdata").html(data);
$("#newsTitle").val('');
$("#newsDetails").val('');
$("#newsDate").val('');
$("#id").val('');
}
});
return false;
});
});
and insert query is
$ins="insert into news set title='".$_POST['newsTitle']."',
detail='".$_POST['newsDetails']."',
date='".$_POST['newsDate']."'
";
mysqli_query($conn,$ins);
Any help will be appreciated.