views:

165

answers:

1

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;
+1  A: 

Well, I don't understand this at all:

({ tags:[{tag:'asdasd',freq:'4'}]}){tag:'asdasdsadasd',freq:'4'}]}){tag:'xcvxcvcx',freq:'2'}]}){tag:'cvbvcbcbvbcv',freq:'11'}]})

Are you intending something more like this:

{ tags:[    {tag:'asdasd',freq:'4'},
            {tag:'asdasdsadasd',freq:'4'},
            {tag:'xcvxcvcx',freq:'2'},
            {tag:'cvbvcbcbvbcv',freq:'11'}
        ]
};
patrick dw