XDomain JavaScript 跨域请求库

程序名称:XDomain

授权协议: MIT

操作系统: 跨平台

开发语言: JavaScript

XDomain 介绍

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

  • Easy XHR access to file servers:

  • 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 官网

https://github.com/jpillora/xdomain

相关编程语言

MuPlayer 是一款跨平台、轻量级的音频播放解决方案,...
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个...
DewPlayer音乐播放器,样式很简单,而且很实用.播放器...
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Fla...
Speakker 是一个基于 Web 浏览器的音乐播放器,只提...
Player Framework 是一个开源的支持 HTML5 的视频播...