3

jQuery (BaseCamp API 用) を使用して ajax 経由で投稿リクエストを作成しようとしていますが、うまく動作しないようです。curl を使用して問題なく動作させることができるので、jQuery で間違っていることはわかっています。動作するcurlコマンドは次のとおりです。

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

誰にもアイデアはありますか?

ありがとう!

4

2 に答える 2

4

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

その他のオプションについては、 Nathan の投稿を参照してください。

于 2009-08-24T23:49:02.813 に答える
2

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

于 2009-08-26T04:14:42.527 に答える