jQuery(BaseCamp API用)を使用してajax経由で投稿リクエストを作成しようとしていますが、動作させることができません。私はカールをうまく使って動作させることができるので、jQueryに間違っていることが分かります。ここで働くcurlコマンドです:jQuery AJAXポストが動作しませんが、カールで動作します
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -u my.user.name:my.password -d "<time-entry><person-id>123456</person-id><date>08/23/2009</date><hours>8</hours><description>This is a test.</description></time-entry>" https://my.url.updatelog.com/todo_items/1234567/time_entries.xml
、ここでは、私はjQueryを使ってしようとしているコードです:
var post_url = bc_base_url + "/todo_items/" + todo_id + "/time_entries.xml";
var xmlData = "<time-entry><person-id>" + bc_user_id + "</person-id>" +
"<date>" + date + "</date>" +
"<hours>" + time + "</hours>" +
"<description>" + description + "</description>" +
"</time-entry>";
$.ajax({
type: "POST",
url: post_url,
data: xmlData,
dataType: "xml",
contentType: "application/xml",
username: "my.user.name",
password: "my.password",
processData: false,
success: function(msg) {
alert("successfully posted! msg: " + msg + ", responseText = " + this.responseText);
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
alert("error : " + textStatus + ", errorThrown = " + errorThrown);
alert("this.reponseText = " + this.responseText);
}
})
誰もが任意のアイデアがありますか?
ありがとうございます!
Firebugで表示するとエラーになるのはなぜですか?それはドメイン間の問題かもしれませんか? – seanmonstar
あなたは同じドメインに投稿していますか? – karim79
受け入れられた回答のリンクは、Go-Daddyの駐車ドメインページに移動します。 –