2009-08-24 25 views
2

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); 
       } 
      }) 

誰もが任意のアイデアがありますか?

ありがとうございます!

+1

Firebugで表示するとエラーになるのはなぜですか?それはドメイン間の問題かもしれませんか? – seanmonstar

+0

あなたは同じドメインに投稿していますか? – karim79

+1

受け入れられた回答のリンクは、Go-Daddyの駐車ドメインページに移動します。 –

答えて

4

karim79によると、別のドメインに投稿することはできません。

詳細については、Nathan's postを参照してください。

2

これをサーバーに送信し、アプリケーションコードからbasecampに投稿を渡して、メッセージを戻します。

関連する問題