-2
我的jquery ajax響應總是返回0.請幫助我在哪裏做錯了。在stackoverflow的所有其他答案已經過測試,但它沒有奏效。 這裏是我的代碼jQuery ajax總是返回0
jQuery.ajax({
type: "POST",
url: woocommerce_params.ajax_url, //this give the correct url which is http://redhawk-studio.com/demos/rizwan/enrolment/wp-admin/admin-ajax.php
data: {
action: "my_test_action",
status_discount: status_discount1
},
success: function (data) {
alert(data);
}
});
這裏是我的PHP代碼
if($_POST['action'] == 'my_test_action'){ echo 'kkkkk'; exit; }
實際上你的php返回了什麼?看看你的瀏覽器開發工具 –
返回0 – user3376865
'0'在你所顯示的代碼中是無處可見的,它不會輸出或返回任何計數器值或類似的東西。 Ergo:_That_代碼是_not_「返回0」。 – CBroe