<script type="text/javascript">
function httpGetAsync(theUrl, callback)
{
xmlHttp = null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
xmlHttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp != null)
{
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
callback(xmlHttp.responseText);
}
else
{
console.error("Problem retrieving XML data");
}
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.setRequestHeader('Access-Control-Allow-Origin', '*');
xmlHttp.send(null);
}
else
{
console.error("Your browser does not support XMLHTTP.");
}
}
function showIcibaDS(ds_data)
{
// show daily sentence
content = ds_data.content;
note = ds_data.note;
document.write(content + '<br>');
document.write(note);
}
httpGetAsync("http://open.iciba.com/dsapi/", showIcibaDS);
</script>
XMLHttpRequest cannot load http://open.iciba.com/dsapi/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 501.
<script type="text/javascript">
var cur_date = new Date();
document.getElementById("cur_year").innerHTML = cur_date.getFullYear();
function showIcibaDS(ds_data)
{
// show daily sentence
content = ds_data.content;
note = ds_data.note;
ds_p = document.getElementById("iciba_ds")
var content_span = document.createElement('span');
var note_span = document.createElement('span');
var br = document.createElement('br')
content_span.innerHTML = content
note_span.innerHTML = note
ds_p.appendChild(content_span);
ds_p.appendChild(br);
ds_p.appendChild(note_span);
}
</script>
<script type="text/javascript" src="http://open.iciba.com/dsapi/?callback=showIcibaDS"></script>
function jsonp(setting)
{
setting.data = setting.data || {}
setting.key = setting.key||'callback'
setting.callback = setting.callback||function(){}
setting.data[setting.key] = '__onGetData__'
window.__onGetData__ = function(data) {
setting.callback (data);
}
var script = document.createElement('script')
var query = []
for(var key in setting.data)
{
query.push(key + '=' + encodeURIComponent(setting.data[key]))
}
script.src = setting.url + '?' + query.join('&')
document.head.appendChild(script)
document.head.removeChild(script)
}
jsonp({
url: 'http://photo.sina.cn/aj/index',
key: 'jsoncallback',
data: { page: 1, cate: 'recommend' },
callback: function(ret) {
console.log(ret)
}
})
<script src="js/jquery-1.11.3.js"></script>
<script>
$(function(){
$.ajax({
async: true,
type: "GET",
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'callbackfunction',
url: "http://open.iciba.com/dsapi/",
data: "",
timeout: 3000,
contentType: "application/json;utf-8",
success: function(data) {
console.log(data);
}
});
})
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有