如何在使用dreamweaver phonegap的div上显示来自网址(跨网域)的数据? [英] How Display data from url(cross-domain) on div using dreamweaver phonegap?
本文介绍了如何在使用dreamweaver phonegap的div上显示来自网址(跨网域)的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的HTML Dreamweaver Phonegap的div上显示网址的一些内容(#somediv)的最佳方式
What is the best way to display some content of a url (#somediv) on a div of my HTML Dreamweaver Phonegap
我是新的Phonegap DW和i要显示此网页的天气值:
I am new on Phonegap DW and i want to display the weather values of this page:
http://www.catedralaltapatagonia.com/invierno/partediario.php?default_tab=0
在Java U中使用Jsoup,但我不知道如何在DW
In Java U used Jsoup, but i am not sure how do it on DW
我试过这个代码(AJAX和JSONP)
I tried this code (AJAX and JSONP)
HTML
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.5.min.js"></script>
<script src="js/load-json.js"></script>
</head>
<body>
<div id="output"></div>
</body>
</html>
JS
$(document).ready(function(){
var output = $('#output');
$.ajax({
url: 'http://www.catedralaltapatagonia.com/invierno/partediario.php? default_tab=0',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item){
var landmark = '<h1>'+item.name+'</h1>'
;
output.append(landmark);
});
},
error: function(){
output.text('There was an error loading the data.')
}
});
});
推荐答案
我认为你必须启用CORS可以通过以下方式启用cors:
i think you have to enabled CORS for this, you can enable cors via:
.htaccess
Header set Access-Control-Allow-Origin "*"
或通过
.php (together with the codes)
<?php
header("Access-Control-Allow-Origin: *");
?>
这篇关于如何在使用dreamweaver phonegap的div上显示来自网址(跨网域)的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文