I am sending data to php from javascript in this format :
var str = $('#description').summernote('code');
var formData = $('#form').serialize();
var formData2=formData+'&data='+encodeURIComponent(str);
$.ajax({
type: 'POST',
url: 'test.php',
data: formData2,
cache: false,
success: function (data) {
}
});
But, I'm unable to get the data in php. I'm using :
$title=$_POST['title'];
to get title but it says that the index is not found and this it is an array and not a string . HOw can I get 'title' data along with many other values?
But ,
$myfile = fopen("test.txt", "a") or die("Unable to open file!");
fwrite($myfile, var_export($_POST, true));
fclose($myfile);
gives me this :
array (
'title' => 'test title',
'from_datetime' => '',
'sno' => ''22,
)
raw format from javascript console:
title=test%20title&from_datetime=&description=br%3E%3C%2Fp%3E%3Cp%3E-----
form:
<div id="form_div" >
<form id="form" method="post" action="javascript:submit_data();" >
<div class="col-xs-12 col-sm-12">
<input name="title" id="title" placeholder="title" type="text" class="form-control" >
</div>
<div class="col-xs-12 col-sm-12">
<input name="desc" id="desc" placeholder="desc" type="text" class="form-control" >
</div>
</div>