【发布时间】:2012-04-24 06:49:13
【问题描述】:
好的,我有一个这样结束的 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");
}
});
});
编辑源
【问题讨论】:
-
您的
return 1语句是否在函数中调用? -
您应该将 1 输出为 JSON。
-
@RPM。您使用两个波浪号 = `code` 编写代码
-
@gdoron 感谢您的提醒。
-
@RPM。你的意思是
Thanks for the heads up... :)