所以,我正在进行AJAX调用并将其发送到PHP文件。它处理它,它实际上保存到数据库。所以,实际上AJAX正在发挥作用。但是,当它返回时,它显然读作错误,因为我收到与错误消息相关的警报..这是我的javascript文件中的ajax ...
$.ajax({
type: "POST",
url: "printMail.php?do=insertExport",
dataType: "json",
data: {'dtData': JSON.stringify(delTick)},
success: function (resp) {
console.log(resp);
alert("Made it here");
},
error: function (err) {
console.log(err);
alert("Delivery ticket was not saved!");
}
});
现在,php会有点奇怪,因为我们使用内部API来写入数据库...但是这里是..
$values = json_decode($_REQUEST['dtData']);
// var_dump($dtData);
try {
$saveExp = $this->dbp->callMethod("exportdeliveryticket", 'saveDeliveryTicket', $values);
echo json_encode($saveExp);
} catch (Exception $e) {
throw new Exception("Failed while saving delivery ticket " . $e);
}
最后,这是我通过控制台的回复......
"status":"SUCCESS","message":"Successfully called","data":[{"book":"2",".... etc, etc...
同样,它正在保存到数据库,但是,js认为它是失败的,我不明白为什么......
答案 0 :(得分:2)
corpus = [
"The blue dog Blue",
"Green the green cat",
"The green mouse",
]
# CountVectorizer character 2-grams with word boundaries
vectorizer = CountVectorizer(analyzer='char_wb', ngram_range=(2, 2), min_df=1)
X = vectorizer.fit_transform(corpus)
vectorizer.get_feature_names()
[' b',
' c',
' d',
' g',
' m',
' t',
'at',
'bl',
'ca', ....
和parseerror
正是您所怀疑的:您要求jQuery将结果解析为JSON,但它没有有效的JSON(它也有一些HTML可用)
确保结果是有效的JSON(或者,如果你想要HTML,不要告诉jQuery将其解析为JSON)并且它将成为一个成功的事务。