Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails中ruby中的XMLHttpRequest.withCredentials_Ruby On Rails_Xmlhttprequest - Fatal编程技术网

Ruby on rails rails中ruby中的XMLHttpRequest.withCredentials

Ruby on rails rails中ruby中的XMLHttpRequest.withCredentials,ruby-on-rails,xmlhttprequest,Ruby On Rails,Xmlhttprequest,我想从浏览器向配置了XHR的服务器发出HTTP请求,凭据为:true 我找到了java脚本的文档 RubyonRails中有类似的东西吗 这是否与我的要求相关 谢谢。我通过在JS文件中添加以下行并将文件放置在路径app/assets/javascripts/中,并将其包含在app/assets/javascripts/application.JS中,作为/=require-dummy\u请求 dummy_request.js包含: var xhr = new XMLHttpRequest();

我想从浏览器向配置了XHR的服务器发出HTTP请求,凭据为:true

我找到了java脚本的文档

RubyonRails中有类似的东西吗

这是否与我的要求相关


谢谢。

我通过在JS文件中添加以下行并将文件放置在路径
app/assets/javascripts/
中,并将其包含在
app/assets/javascripts/application.JS
中,作为
/=require-dummy\u请求

dummy_request.js包含:

var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com/', true);
xhr.withCredentials = true;
xhr.send(null);
使用上述技术,您可以在第一次打开页面时发送请求。如果您想对每个特定的时间间隔发出请求,可以使用以下方法:

setInterval(function(){     var xhr = new XMLHttpRequest();
    xhr.open('GET', 'http://example.com/', true);
    xhr.withCredentials = true;
    xhr.send(null); }, 3000);
使用上述代码,您可以每隔3秒发送一次请求


谢谢。

我通过在JS文件中添加以下行并将文件放置在路径
app/assets/javascripts/
中,并将其包含在
app/assets/javascripts/application.JS
中,作为
/=require-dummy\u请求

dummy_request.js包含:

var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://example.com/', true);
xhr.withCredentials = true;
xhr.send(null);
使用上述技术,您可以在第一次打开页面时发送请求。如果您想对每个特定的时间间隔发出请求,可以使用以下方法:

setInterval(function(){     var xhr = new XMLHttpRequest();
    xhr.open('GET', 'http://example.com/', true);
    xhr.withCredentials = true;
    xhr.send(null); }, 3000);
使用上述代码,您可以每隔3秒发送一次请求

谢谢