Data inserted in database, but ajax calls error function

Solved. Works fine without dataType: json in ajax-script.js and header('Content-Type: application/json'); in php file