2013-05-07 69 views
0

嘿傢伙即時有一個愚蠢的問題與AJAX PUT後,我嘗試把JSON數據回服務器認爲它的XML數據,即使我使用:dataType:「應用程序/ JSON」,任何想法,爲什麼這可能他在發生?這是我的PUT的樣子:Ajax PUT數據類型問題

$.ajax({ 
type: "PUT", 
url: bank_url, 
dataType: "application/json", 
data: {"banking_detail_id": page.viewModel.payer_banking_detail_id(), 
"person_id": person_id, "account_number": page.viewModel.payer_account_number(), 
"branch": page.viewModel.payer_branch(), "date_inserted": page.viewModel.payer_date_insterted(), 
"date_effective": page.viewModel.payer_date_effective(), "account_type": page.viewModel.payer_account_type(), 
"account_holder": page.viewModel.payer_account_holder() , "debit_day": page.viewModel.payer_debit_day() , 
"branch_code": page.viewModel.payer_branch_code() , "bank_branch_id": page.viewModel.payer_bank_branch_id(), 
"branch_name": page.viewModel.payer_branch_name(), "bank_name": page.viewModel.payer_bank_name(), 
"user_id": page.viewModel.payer_user_id()}, 
}); 

服務器這樣的迴應:

XHR = { 「長度」:847, 「名」: 「錯誤」, 「嚴重」:「ERROR 「,」code「:」23502「,」detail「:」失敗 行包含(null,1081563,12341234,ABSA ELECTRONIC SETTLEMENT CNT (632005),2013-05-05 00:00:00,2013-05- 06,0,Coetzee MA,1,null, 0)。「,」where「:」SQL statement \「INSERT INTO banking_detail( \ n \ t \ t \ t \ tbanking_detail_id,\ n \ t \ t \ t \ tperson_id, \ n \ t \ t \ t \ taccount_number, \ n \ t \ t \ t \ t分支,\ n \ t \ t \ t \ tdate_inserted, \ n \ t \ t \ t \ tdate_effective,\ n \ t \ t \ t \ taccount_type, \ n \ t \ t \ t \ taccount_holder,\ n \ t \ t \ t \ tdebit_day, \ n \ t \ t \ t \ tbank_branch_id,\ n \ t \ t \ t \ tuser_id)\ n \ t \ t \ tVALUES \ n \ t \ t \ t \ tnew.banking_detail_id,\ n \ t \ t \ t \ tnew.person_id,\ n \ t \ t \ t \ tnew.account_number,\ n \ t \ t \ t \ tnew .branch,\ n \噸\噸\噸\ tnew.date_inserted,\ n \噸\噸\噸\ tnew.date_effective,\ n \噸\噸\噸\ tnew.account_type,\ n \噸\噸\噸\ tnew.account_holder,\ n \噸\噸\噸\ tnew.debit_day,\ n \噸\噸\噸\ tnew.bank_branch_id,\ n \噸\噸\噸\ tnew.user_id)\「\ NPL/pgSQL的 功能banking_detail_view_set(),在SQL語句 」, 「文件第4行」: 「execMain.c」, 「行」: 「1527」, 「程序」: 「ExecConstraints」}

+0

到底是由服務器產生什麼反應?它包括'xhr ='? – Dogbert 2013-05-07 12:17:12

回答

1

請求類型是GET或POST 例如:

type: "GET", 
    type: "POST", 

和數據類型是XML,JSON,腳本或HTML 例如:

dataType:'html', 
    dataType:'xml', 
    dataType:'json', 
    dataType:'script', 
+0

是的抱歉,我沒有包括主鍵:P – 2013-05-07 12:27:15

+1

所有主流瀏覽器也支持PUT和DELETE。 – user1751825 2015-06-25 09:43:24

+0

不錯的複製粘貼從互聯網上,但你忘了輸入'文本'也 – vsync 2016-10-15 14:29:49