我有a little web app我正在使用它来测试 CSS 动画。我已经让它工作了,但我想要更多真正的随机性,所以我试图从 Random.org 中抽取. 如何取the result from Random.org转换成 JavaScript 变量并将其用作 int?
最佳答案
您使用 $.ajax
加载站点,然后使用 parseInt(x)
并将其传递给一个函数来处理随机性。
例如:
$.ajax({
"type": "GET",
"url": "http://www.random.org/integers/?num=1&min=1&max=6&col=1&base=10&format=plain&rnd=new",
"success": function( data, status, xhr ){
send_the_number_to_a_handler( parseInt( data ) );
}
});
关于javascript - 将 Random.org 数据解析为 JS 中的 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14743920/