I am using Summernote text editor. I am collecting HTML in following way:
var luck = $(".textEditor").code();
my content as of now is as follows :
<p><br></p>
<img src="http://127.0.0.1/gallery/1/0336dcbab05b9d5ad24f4333c7658a0e.jpeg" style="width: 640px;"><p>Tell your travel story...</p>
I am making following ajax request to send it to PHP
$.ajax({
dataType : 'json',
async : true,
cache : false,
beforeSend : function(xhr) {
xhr.setRequestHeader("Accept", "application/json");
},
data: {
'luck' : luck
},
type: "POST",
url: "<?php echo base_url(); ?>index.php/travelogue/postBlog",
cache: false,
success: function(data, status, xhr) {
alert(data);
},
error:function(xhr, textStatus, errorThrown) {
alert(xhr); alert(xhr.status); alert(textStatus); alert(errorThrown); alert(xhr.statusText); alert(xhr.responseText); }
});
on PHP side I am getting data in following way (for example sake I am just puting data in txt file(
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, $_POST["luck"]);
fclose($myfile);
But I get following content. From IMG tag STYLE tag is missing.
<p><br></p><img src="http://127.0.0.1/gallery/1/0336dcbab05b9d5ad24f4333c7658a0e.jpeg" 640px;"><p>Tell your travel story...</p>
I am not sure how to retrieve data properly? Is there problem with ajax request or may be i am not getting data in PHP in correct way?
Any suggestions would be helpfull....
Thanks