好的,我有一个
PHP脚本,结尾如此:
if ($success)
{
$result = array('success' => true);
}
else
{
$result = array('success' => false,'message' => 'Something happened');
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error',true,500);
}
echo json_encode($result);
还有一些jquery,我计划在我的脚本运行时提醒我.
jQuery(document).ready(function() {
$.ajax({
url: './contactengine.PHP',type: 'GET',dataType: 'JSON',success: function(response) {
alert("GOOD");
},error: function() {
alert("BAD");
}
});
});
编辑来源
<?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>