jquery标签云错误?
我有一个问题。我在我的网站上制作了一个标签云,但它不起作用:(
({
tags: [{
tag: 'asdasd',
freq: '4'
}]
}) {
tag: 'asdasdsadasd',
freq: '4'
}]
}) {
tag: 'xcvxcvcx',
freq: '2'
}]
}) {
tag: 'cvbvcbcbvbcv',
freq: '11'
}]
})
这是 PHP 文件的响应,我想用我的 html 获取它 -
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript">
$(function() {
//get tag feed
$.getJSON("tagcloud.php?callback=?", function(data) {
//create list for tag links
$("<ul>").attr("id", "tagList").appendTo("#tagCloud");
//create tags
$.each(data.tags, function(i, val) {
//create item
var li = $("<li>");
//create link
$("<a>").text(val.tag).attr({title:"See all pages tagged with " + val.tag, href:"http://localhost/tags/" + val.tag + ".html"}).appendTo(li);
//set tag size
li.children().css("fontSize", (val.freq / 10 < 1) ? val.freq / 10 + 1 + "em": (val.freq / 10 > 2) ? "2em" : val.freq / 10 + "em");
//add to list
li.appendTo("#tagList");
});
});
});
</script>
我使用 tuts.com 的这个脚本来编写它PHP 回调和返回是
$response = $_GET["callback"] . $json;
echo $response;
mysql_close($server);
请告诉我为什么它不起作用
是的,我做了你的建议,它工作正常
,但现在我可以得到这些值。 我的 MySQL 表是 UTF8 通用 ci,我的 HTML 也是 utf8 编码。
我想让 PHP“echo $response” 为 UTF8。有什么建议吗?我的脚本现在看起来像这样
$response = $_GET["callback"] . $json; echo $response;
I've got a problem. I made a tag cloud thingy to my website, but it doesn't work :(
({
tags: [{
tag: 'asdasd',
freq: '4'
}]
}) {
tag: 'asdasdsadasd',
freq: '4'
}]
}) {
tag: 'xcvxcvcx',
freq: '2'
}]
}) {
tag: 'cvbvcbcbvbcv',
freq: '11'
}]
})
this is the response of the PHP file, and i'd like to get it with my html-
<script type="text/javascript" src="../scripts/jquery.js"></script>
<script type="text/javascript">
$(function() {
//get tag feed
$.getJSON("tagcloud.php?callback=?", function(data) {
//create list for tag links
$("<ul>").attr("id", "tagList").appendTo("#tagCloud");
//create tags
$.each(data.tags, function(i, val) {
//create item
var li = $("<li>");
//create link
$("<a>").text(val.tag).attr({title:"See all pages tagged with " + val.tag, href:"http://localhost/tags/" + val.tag + ".html"}).appendTo(li);
//set tag size
li.children().css("fontSize", (val.freq / 10 < 1) ? val.freq / 10 + 1 + "em": (val.freq / 10 > 2) ? "2em" : val.freq / 10 + "em");
//add to list
li.appendTo("#tagList");
});
});
});
</script>
I used this script from tuts.com to write it to screen. The PHP callback and return is
$response = $_GET["callback"] . $json;
echo $response;
mysql_close($server);
Please tell me why it is not work
Yes, i did what you suggested and its works fine.
But there are another problems. Now i can get the values. For example Gyökér.
My MySQL table is UTF8 general ci and my HTML is utf8 encoded also.
I'd like to make the PHP "echo $response" to be UTF8. Any suggestions? My script now looks like this
$response = $_GET["callback"] . $json; echo $response;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我根本不明白这一点:
您是否打算更像这样:
Well, I don't understand this at all:
Are you intending something more like this: