Send php response to ajax
<?php if ($success){ $result = array("status" => "1"); echo json_encode($result); } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=/404.html\">"; } ?> <script> jQuery(document).ready(function() { $.ajax({ type: 'GET', url: 'Thatscriptsomething.php', cache: 'false', dataType: 'json', success: function(response) { if(response.status == "1") { alert("we having a working script"); } else { alert("Oops, script is a no go"); } } }); }); </script>
Basic example - it works for me
PHP RESPONSE
$value = array('msg' => 'true' ); echo json_encode($value);
AJAX METHOD
$.ajax({ type: 'post', url: 'URL', contentType: false, processData: false, dataType:'JSON', data: formData, success: function(value) { if (value.msg == 'true') { //your action }else{ //your action } }});