JavaScript跨域请求库XDomain.zip

时间:2022-08-06 16:59:04
【文件属性】:
文件名称:JavaScript跨域请求库XDomain.zip
文件大小:216KB
文件格式:ZIP
更新时间:2022-08-06 16:59:04
开源项目 XDomain 是 JavaScript CORS 跨域请求的一个替代产品,无需任何服务器端的配置。只需要在同域下放置一个 proxy.html 文件即可。该库利用 XHook 来获取所有 XHR,可以无缝的和其他库协同工作。 Features Simple Library Agnostic With jQuery  $.ajax (and subsequently $.get, $.post) With Angular $http service Cross domain XHR just magically works No need to modify the server code No need to use IE's silly XDomainRequest Object Easy XHR access to file servers: Amazon Dropbox Includes XHook and its features proxy.html files (slaves) may: White-list domains White-list paths using regular expressions (e.g. only allow API calls: /^\/api/) Highly performant Seamless integration with FormData 示例代码: //do some vanilla XHR var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://xyz.example.com/secret/file.txt'); xhr.onreadystatechange = function(e) {   if(xhr.readyState === 4)     alert(xhr.responseText); }; xhr.send(); //or if we are using jQuery... $.get('http://xyz.example.com/secret/file.txt').done(function(data) {   console.log("got result: ", data); }); 标签:XDomain
【文件预览】:
xdomain-gh-pages
----.gitignore(31B)
----README.md(13KB)
----package.json(885B)
----dist()
--------xdomain.min.js(41KB)
--------xdomain.map(158KB)
--------xdomain.js(84KB)
----src()
--------browser.js(198B)
--------vendor()
--------index.js(574B)
--------lib()
----example()
--------dropbox()
--------formdata()
--------performance()
--------requirejs()
--------angular()
--------browserify()
--------fileuri()
--------jquery2()
--------blob()
--------local()
--------files()
--------echo()
----.travis.yml(267B)
----index.html(2KB)
----package-lock.json(279KB)

网友评论