I have the following script:
<script type="text/javascript">
$.getJSON("http://api.twitter.com/1/statuses/user_timeline/koawatea.json?count=1&include_rts=1&callback=?", function(data)
{
$("#headertweet").html(data[0].text);
});
</script>
It have created a test document that works offline.
But this does not work when I put it online (live or on my local XAMPP setup).
Can somebody tell me why, please?
Here’s the CSS:
#headertwitterbox {
width: 200px;
height: 100px;
background:url(http://i48.tinypic.com/169ruab.jpg) no-repeat;
font-family: 'Source Sans Pro', sans-serif;
font-size: 7pt;
}
#headertweet {
width: 180px;
height: 53px;
float:left;
margin-left: 10px;
margin-top: 6px;
}
HTML:
<div id="headertwitterbox" style="float:left;">
<div id="headertweet"></div>
</div>
That would be your problem. You are calling it before the element’s are loaded so it probably is not finding the element because it has not been created by the time the response comes back. Place the script after the element
headertweetOR call it on document ready.After:
In Head with doucument ready:
EDIT – Changed because you gave the link and the error is related to something else!
In the sample link you have errors! You defined jQuery in no conflict mode, BUT you are using $! Change the $ over to jQuery!