I'm trying to do an Ajax call, to show suggestions when a #hashtag is typed in a text box. For test purpose i'm trying to retrieve the $_POST[] data itself.
home.php
<textarea class="status" name="status" ></textarea>
<div class="hash-box">
<ul></ul>
</div>
hashtag.js
In here the console.log(data)
outputs
<li> <span class="getValue">Array</span></li>
Array is getting returned instead of the value.
$(function(){
var regex = /[#|@](\w+)$/ig;
$('.status').keyup(function(){
var content = $.trim($(this).val());
var text = content.match(regex);
if(text!=null){
//var data = 'data='+text;
$.ajax({
url:'./hashtag.php',
type:"POST",
data:{datas:text},
cache:false,
success:function(data){
console.log(data);
}
});
}
});
});
hashtag.php
<?php
echo '<li><span class="getValue">'.$_POST['datas'].'</span></li>';
?>
I tried var_dump($_POST['datas'])
in hashtag.php
and it works.