获取jQuery UI主题列表 - 从URL(同源策略) [英] Get List of jQuery UI themes - from an URL (same-origin-policy)
问题描述
有没有人知道从 http获取jQuery主题列表的方法://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/ ?
我正在创建带主题滚轴的简单网页用户可以动态切换主题。
I am creating simple webpage with themes roller where the user can switch themes dynamically.
工作小提琴 - 点击右上角的主题并选择一个新主题。
Working fiddle - Click on Themes on Right top corner and select a new theme.
现在列表被硬编码为
<div id="theme-list">
<ul>
<li class="themes-el ui-state-highlight" data-theme="cupertino">cupertino</li>
<li class="themes-el" data-theme="hot-sneaks">hot-sneaks</li>
<li class="themes-el" data-theme="smoothness">smoothness</li>
<li class="themes-el" data-theme="pepper-grinder">pepper-grinder</li>
<li class="themes-el" data-theme="ui-lightness">ui-lightness</li>
<li class="themes-el" data-theme="ui-darkness">ui-darkness</li>
<!-- and more -->
</ul>
</div>
有一种方法可以从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 )
Is there a way to get this list of themes from 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)
尝试,但失败,
Tried, but failed with below code..
$.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);
}
});
感觉像我在这里失踪了很多。
It feels like I am missing a lot here.. any insight would really help.
推荐答案
我从找到此服务 yahoo(YQL) 和 此跨网域请求与jQuery插件 ,使用YQL获取跨域内容。
I found this service from yahoo(YQL) and this Cross-domain requests with jQuery plugin that uses YQL to fetch cross domain content.
http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
DEMO: http://jsfiddle.net/SXHrB/4/
下面的代码简单地抓取了我解析的整个页面,以获取所需的内容。
The below code simply fetched me the whole page which I parsed to get the required content.
$.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('<ul>'), data.responseText.lastIndexOf('</ul>') + 4));
}
});
这篇关于获取jQuery UI主题列表 - 从URL(同源策略)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!