i got the following js script submitting form html content:
$.ajax({
url : 'include/speakers.php',
type : 'POST',
data : "htmlText="+htmlField",
dataType : 'html',
success : function (result) {
},
error:function (xhr, ajaxOptions, thrownError){
$( ".phpMessage" ).html( " - "+thrownError );
}
});
Speakers Php Looks like:
$htmlTextVar = $_POST['htmlText'];
$stmt = $mysqli->prepare("UPDATE table SET htmlText = ? WHERE id = ?");
$stmt->bind_param('si', $htmlTextVar, $id);
$stmt->execute();
Now, the issue is when I submit html text like
<p class="MsoNormal"><span lang="EN-US"> </span>
its only storing the text until
. So text inside the database table is
<p class="MsoNormal"><span lang="EN-US">
Have no idea how to solve this :(
put your data on encodeURIComponent()
$.ajax({
url : 'include/speakers.php',
type : 'POST',
data : "htmlText=" + encodeURIComponent(htmlField),
dataType : 'html',
success : function (result) {
},
error:function (xhr, ajaxOptions, thrownError){
$( ".phpMessage" ).html( " - "+thrownError );
}
});
and on your php file
$htmlTextVar = urldecode($_POST['htmlText']);