我有一個小腳本,它將運輸成本從PHP/CodeIgniter返回到HTML中。Ajax和json_encode在Firefox中回顯文本而不是json
這裏的PHP代碼,與陣列的一些示例數據:
public function atualiza_frete_ajax() {
$response_array = array(
'html_select_frete' => "<form><select><option></option></select></form>"
);
header("Content-Type: application/json", true);
echo json_encode($response_array);
}
而且JS/jQuery的
function atualizar_frete_ajax() {
var $form = $("#form-cep");
$(".loading").fadeIn();
$.ajax({
type: $form.attr("method"),
url: $form.attr("action"),
dataType: "json",
data: $form.serialize()
}).done(function(data){
$(".frete-valor").html(data.html_select_frete)
$(".loading").hide()
});
event.preventDefault();
}
現在的問題是:它在Chrome的偉大工程,但在Firefox我只是得到這個令人討厭的文本輸出。
這裏的FF如何輸出它的PRINTSCREEN:http://prntscr.com/5cfcgc
我已確認該文件的編碼是UTF8並沒有BOM,和我使用的是正確的標題之前,我附和響應。
任何線索?
可以包括一個小的屏幕捕獲? – morne 2014-12-02 13:52:35
您使用的是哪個版本的FireFox和jQuery? – MonkeyZeus 2014-12-02 13:55:00
你有舊的FireFox版本嗎?還要注意'event.preventDefault();'在這裏沒用。 – 2014-12-02 13:55:35