我有一个无法调试的 JSON 解析错误。下面的代码:
$(document).on('submit', '#confirmreset', function(event) {
event.preventDefault();
var action_url = $(this).attr("action");
alert_box_register("Resetting password...");
console.log(action_url);
var postData = $(this).serializeArray();
console.log(postData);
$.post(action_url, postData, function(data) {
console.log(data);
var obj = $.parseJSON(data);
alert_box_register(obj.message);
});
});
和 JSON:
{
"status": "success",
"message": "A temporary password has been emailed to you."
}
在 Firefox 中,错误是“SyntaxError: JSON.parse: unexpected character”,在 Chrome 中是“Uncaught SyntaxError: Unexpected token C”
有任何想法吗?
*编辑:这适用于我的本地主机设置。*