我想用AJAX JSONP查询从我在Cloudant上托管的CouchDB读取文档。Ajax查询和Smarty错误
This是网页。以下是相关的代码部分。
<script type="text/javascript">
var url = "https://acharya.cloudant.com/toxtweet";
console.log(url);
function getCloudantData(url) {
$.ajax({
'url': url,
'dataType': 'jsonp'
},
function (data) {
$('#importeddata').text(data);
});
}
</script>
但是,当我把这个脚本标签放入该网页时,我只是得到一个空白的网页,我不知道为什么。我甚至没有调用函数,JSLint说没有语法错误。
模板HTML文件
{extends file='toxtweet.tpl'}
{block name="head"}
<link href="./styles/poll.css" rel="stylesheet" type="text/css" media="Screen">
<script type="text/javascript">
var url = "https://acharya.cloudant.com/toxtweet";
console.log(url);
$(function(){
$.ajax({
'url': 'https://acharya.cloudant.com/toxtweet',
'dataType': 'jsonp',
success:function (data) {
$('#ing').text(data);
}});});
</script>
{/block}
{block name="body"}
<h2> Do you think this tweet is discussing drugs? </h2>
<form class="poll" method="post" actions="">
<p id="chosen-tweet"><p>
<ul>
{foreach $answers as $answer}
<li>
<label class="poll_active">
<input type="radio" name={$answer} value="0">{[email protected]}
</label>
</li>
{/foreach}
</ul>
</form>
<div id="ing"></div>
{/block}
{debug}
的https://acharya.cloudant/com/toxtweet给我一个超时 - 这就是给你一个空白页。 – m02ph3u5
有趣。当我从浏览器访问“https://acharya.cloudant.com/”时,我得到了“{”couchdb“:”Welcome“,”version“:”1.0.2“,”cloudant_build“:” 850“}” – mac389
你的[proxy](http://tox.sinaiem.org/scripts/proxy.js)脚本应该使用[node.js](http://nodejs.org/), – extramaster