我无法理解单引号来自json格式。
这是ajax
$().ready(function() {
$("form#saveForm").validate({
debug: true,
onkeyup: false,
submitHandler: function(form) {
var form = new FormData($("#saveForm")[0]);
console.log(form);
$.ajax({
type: "post",
url: "<?php echo base_url('admin_seo_controller/assignDomainToUser/'); ?>",
data: new FormData($("#saveForm")[0]),
contentType: false,
processData: false,
success: function(data) {
console.log(data);
jdata = $.parseJSON(data);
console.log(jdata);
if (jdata.status_code == 200) {
$("#d_conf_msg").empty().html("<p>Success!</p>").dialog('open');
} else {
$("#d_notif_msg").empty().html("<p>" + jdata.status_desc + "</p>").dialog('open');
}
}
});
},
rules: {
file: {
required: true
}
},
messages: {
file: "This is field is required!"
}
});
});
这是输出
的json格式'{"status_code":200,"status_desc":"Success!"}
错误是
Uncaught SyntaxError: Unexpected token ' in JSON at position 0
at Function.parse [as parseJSON] (<anonymous>)
这是我试图编码的json的数据
$response = array(
'status_code' => 200,
'status_desc' => 'Success!'
);
希望有人可以帮助我。