我有这个网站:我的AJAX调用不返回任何东西,但没有失败或者
<input type="text" id="text"/>
<input type="button" id="submit" value="Submit" />
<div id="twitter_update_list">
</div>
与此javascript:
var xmlHttp;
document.body.onclick = function(){
var username = document.getElementById('text').value;
selectUser(username);
}
function selectUser(username){
var url = "http://twitter.com/statuses/user_timeline/" + username + ".json?callback=twitterCallback2&count=100";
try{// Opera 8.0+, Firefox, Safari
xmlHttp = new XMLHttpRequest();
}catch (e){// IE
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
xmlHttp.onreadystatechange = processRequest;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function processRequest(){
if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
if (xmlHttp.responseText == "Not found") {
document.getElementById('twitter_update_list').innerHtml = "Not found";
}else if(xmlHttp.responseText == " "){
document.getElementById('twitter_update_list').value = "Empty";
}else{
// No parsing necessary with JSON!
document.getElementById('twitter_update_list').value = xmlHttp.responseText;
console.log(xmlHttp.responseText);
}
}
}
我在看萤火,我看到verything被发送正确但我没有得到任何回应。哦,我正在使用原始的JavaScript,因为我想练习它。 =)
+1的usertimeline:不能相信我没有看的URL。 – 2010-02-19 21:49:57
除非他为twitter工作:) – 2010-02-19 22:17:31