Search code examples
javascriptjqueryajaxpastebin

JQuery Ajax request to http://pastebin.com/raw.php


I try to make a JQuery ajax request to 'http://pastebin.com/raw.php' and using this code:

$.ajax({
        url: 'http://pastebin.com/raw.php',
        data: "i=VJ29uFnk",
        complete: function(jqXHR, textStatus) {
            alert('complete');
        },
        success: function(data) {
            alert(data);
        },
        error: function(xhr, status, error) {
            alert('noh!')
        }
});

With this I get a status '404' within xhr but the url I can see in firebug looks correct:

http://pastebin.com/raw.php?i=VJ29uFnk

Ideas?


Solution

  • XHR calls are protected under the Same origin policy.

    What you can do, however, is call a server side script that bypass this.