获取jQuery UI主题列表 – 来自URL(同源策略)

有谁知道从http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/获取jQuery主题列表的方法?

我正在创建带有主题滚动的简单网页,用户可以动态切换主题。

工作小提琴 – 单击右上角的主题并选择一个新主题。

现在列表硬编码如下,

  • cupertino
  • hot-sneaks
  • smoothness
  • pepper-grinder
  • ui-lightness
  • ui-darkness

有没有办法从URL http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/获取这个主题列表? (crossDomain: http : //www.w3.org/TR/cors/#access-control-allow-origin-response-hea )

尝试,但失败了下面的代码..

 $.ajax({ url: 'http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/', dataType: 'text', beforeSend: function ( xhr ) { xhr.setRequestHeader("Access-Control-Allow-Origin", 'http://jquery-ui.googlecode.com'); xhr.setRequestHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); }, crossDomain: true, success: function (data) { alert(data); }, error: function (jqXHR, textStatus, errorThrown) { alert(errorThrown + ' ' + textStatus + ' ' + jqXHR.responseText); } }); 

感觉我在这里错过了很多……任何见解都会有所帮助。

似乎服务器不允许跨域请求。 你什么都做不了。

您可以设置一个可以curl该页面的PHP脚本,然后您就可以调用PHP脚本了。 像kuncajs所说的那样

您可以在服务器上使用这个简短的PHP curl脚本:

  

然后它只是一个简单的ajax脚本:

 $.ajax({ url: "linktoscript.php", dataType: "html", success: function(data) { console.log(data); }, error: function (request, status, error) { console.log(request); console.log(status); console.log(error); } }); 

我从yahoo(YQL)和使用YQL获取跨域内容的jQuery插件发现了这个跨域请求

http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/

演示: http //jsfiddle.net/SXHrB/4/

下面的代码简单地提取了我解析的整个页面以获取所需的内容。

 $.ajax({ url: 'http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/', type: 'GET', success: function(data) { alert(data.responseText.substring(data.responseText.indexOf('
    '), data.responseText.lastIndexOf('
') + 4)); } });

您是否尝试过使用JQuery使用的主题切换器插件:
它将提供JQuery用于演示目的的所有现成主题。

    

你可以让你的网站添加一个这样的风格的链接:

当你点击新主题时,javascript会在头部添加一个链接标签,你可以用这里的任何名字替换链接的ui-lightness部分: http : //jquery-ui.googlecode.com/svn/tags/1.8 .23 / themes /希望这有帮助