在这里尝试回到基础并通过 ajax 将 JSON 对象发送到我的 php.ini 文件。当我收到 JSON 错误时,我什至无法进入那部分。这是jquery代码:
jQuery(".deletebutton").on("click", function() {
var employees = [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName": "Jones" }
];
var dataString = JSON.stringify(employees);
// Lets put our stringified json into a variable for posting
var postArray = {json:dataString};
jQuery.ajax({
type: 'POST',
url: 'index.php?option=com_recordings&task=deletevideos&format=raw',
data: postArray,
dataType: 'json',
success: function(data){
if (data == "blah")
alert(data);
}
});
});
我收到此错误(当我检查时errorThrown
): SyntaxError: JSON.parse: unexpected character。我与 jsonlint.com 确认它是有效的 JSON。我究竟做错了什么?