Jquery and random.org "not allowed Access-Control-Allow-Origin"

I am having trouble querying a random number from random.org using jQuery. When I use a static page and the following javascript, I have no problem getting random numbers. However, I accept the Sinatra application on Heroku (also when I launch my application locally using Thin) I get "(website) Access-Control-Allow-Origin is not allowed."

function raffler(){

var rowCount = $('#winnerTable tr').length;

$('#winnerButton').click(function() {
    $.get("http://www.random.org/integers/?", {num: "1", min: "1", max: rowCount, col: "1", base: "10", format: "plain", rnd: "new"}, function(randNum) {
        var myNumber = randNum;
        $("#entry-" + randNum).addClass('winner');
    });
});

};

Thoughts?

+5
source share
3 answers

, , . . Access-Control-Allow-Origin - XSS, (, Flash). :

Math.random()
+1

, random.org CORS. , Javascript .

, , , file:///? , AJAX.

+3

jQuery YQL-, .

It bypasses the verification of origin using the Yahoo service to get the contents of the necessary page.

http://plugins.jquery.com/project/jquery-yql-plugin

But this is a very difficult way. Why aren't you using Math.random ()?

0
source

All Articles