JQuery $ .post with PasteBin API

Good,

I am trying to use jQuery $ .post with the PasteBin API to create a PasteBin page and grab the url (which the API says it is returning). Here is my code:

$('#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 the PasteBin). However, all that is returned is an empty string. I tried using the same API with php and cURL and I can get the url just fine. Can anyone see me doing something wrong? Thanks!

+4
source share
1 answer

The browser cross-domain security policy does not allow you to make client-side requests in other domains unless they offer the API specifically in a format designed to limit restrictions such as JSONP.

You seem unlucky. You will need to send a request to your own server and send a request to Pastebin on the server side.

+4
source

Source: https://habr.com/ru/post/1310640/


All Articles