jquery ajaxを使用して、PHP関数からデータを取得しています。JQuery Ajax意図的にエラー関数を実行します。
代わりにちょうど何もPHP関数から戻るの私のjavascriptで
$.ajax({
url : '../functions/php/function.php',
type : 'GET',
dataType : 'json',
data : {'wrong','wrong'},
success : function(data) { console.log('all ok') },
error : function(log) { console.log('not ok') }
});
<?php
if(isset($_GET['action'])) {
$data = array();
$data[0]["field"] = "data";
echo json_encode($data);
} else {
// error
return;
}
?>
を次のように私のPHPの関数であると私はjqueryのAJAXを使用して呼び出していますが、それは取得することが可能ですjqueryがエラー関数を実行するようなエラー?
PHPコードから '2xx'以外のステータスコードを返すと、' error'ハンドラが実行されます –
残念ですが、私の怠惰を修正します – Trent
{'wrong'、 'wrong'}はキーのペア:値 – Fky