I have some php and javascript, everythings work and I do not get any error message. I can post data without any error to database. And everythings looks good but I cannot use some function in php.
Example.
I have a textarea and I send its data with ajax to a php file. In php file a need to use str_replace function. I can insert data to database in same php file without any error but the function that I try to use like str_replace or mysqli_real_escape_string, etc. do not work.
What would be the reason?
Here codes.
$(".editBoxButton").click(function(){
var yazi = jQuery('#editInput').val();
$.ajax({
type: 'POST' ,
url : 'ajax/editEntry.php',
data: {
text: yazi,
},
success : function(d){
alert(d);
location.reload(); //refresh
}
});
});
ajax/editEntry.php
<?php
$yeniyazi=$_POST['text'];
$yeniyazi = str_replace("\n", "<br>", $yeniyazi);
$s=$yeniyazi;
echo json_encode($s);
?>
in the alert, I get still \n. it does not replaced.
I do not get any error. only str_replace do not work that is my problem. expect str_replace, it works properly.