試圖發送一個ajax post請求jQuery的AJAX POST請求失敗
function ajaxCall(request_data) {
alert(request_data['table'] + request_data['name'] + request_data['description']);
$.ajax({
type: "POST",
cache: false,
url: "../src/api.php/InsertTo",
data: request_data,
dataType: "json",
contentType: 'application/json',
success: function() {
alert('good');
/* $('form').hide();
$('h3').append("Object Successfully Inserted!");*/
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown + textStatus);
}
});
它的每一次拋出錯誤,「request_data」是一個對象和URL的回報只是一個簡單的字符串現在,請查找問題
在發送JSON請求之前,您是否使用了'JSON.stringify(request_data)'?您還可以在發送給api的問題中共享'request_data'的格式 – Niladri
錯誤是什麼? –
'code' VAR request_data = { '表': '學生', '名':姓名, '電子郵件':電子郵件, '電話':電話 }這是可變的,我檢查每一個參數,它有它的價值 –