5

Ok,

I'm trying to use jQuery $.post with the PasteBin API to create a PasteBin page and grab the URL (which the API says it returns). Here is my code so far:

$('#send_code').click(function(){
    $.post('http://pastebin.com/api_public.php', 
            { paste_name: $('#paste_name').val(), paste_code: $('#paste_code').val() },
            function(data){
                alert(data);
            });
}

The above script creates the page just fine (I can find them on PasteBin). However, all that is returned is an empty string. I've tried using this same API with php and cURL, and I'm able to retrieve the URL just fine. Can anyone see if I'm doing something wrong? Thanks!

4

1 に答える 1

5

ブラウザーのクロスドメイン セキュリティ ポリシーでは、JSONP などの制限を回避するように設計された形式で API を具体的に提供しない限り、他のドメインに対してクライアント側の要求を行うことはできません。

運が悪いようです。リクエストを自分のサーバーに送信し、サーバー側の Pastebin にリクエストを送信する必要があります。

于 2010-05-23T04:12:12.643 に答える