function view_record2()
{
$("#searchbox").keyup(function()
{
var searchword = $(this).val();
$.ajax(
{
url: 'view.php',
method: 'post',
data:{searchword:searchword},
dataType: 'JSON',
success: function(data)
{
data = $.parseJSON(data);
if(data.status=='success')
{
$('#table').html(data.html);
}
}
})
})
}
PHP :
function display_record2()
{
global $con;
$search = $_POST['searchword'];
$value = "";
$value = '<table class="table table-bordered">
<tr>
......
$value.='</table>';
echo json_encode(['status'=>'success','html'=>$value]);
}
When i send data type :text everything is ok , but when i use JSON data type , not working post action.What is the problem with my code? Actually im new to coding so simple mistakes gets very problem to progress .