-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax_json_chrome_fix_1.html
More file actions
54 lines (51 loc) · 1.41 KB
/
ajax_json_chrome_fix_1.html
File metadata and controls
54 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<script>
function getsearch()
{
var search_url='http://search.twitter.com/search.json?callback=mycallback&q=';
/*search_url will fetch you JSON with callback name as mycallback*/
var query='';
query=document.getElementById('query').value;
search_url=search_url+query;
var scrpt_div = document.getElementById('script_div');
scrpt_div.innerHTML = '';
var scrpt_ele = document.createElement('script');
scrpt_ele.src = search_url;
scrpt_div.appendChild(scrpt_ele);
var result_div = document.getElementById('result_div');
result_div.innerHTML = 'loading....';
}
function mycallback(data)
{
/*write code here to do the JOB*/
var html='';
for(var i=0;i<data.results.length;i++)
{
var tweet=data.results[i].text/*aah.. luxury of jus using the data, no parsing*/
html=html+tweet+'<br/>';
}
var result_div = document.getElementById('result_div');
result_div.innerHTML = html;
}
</script>
</head>
<body>
<div>
<form action="javascript:void(0)">
<input id="query" type="text"></input>
<input type="submit" onclick="getsearch();" value="search"></input>
</form>
</div>
<div id="result_div">
<!--Here your Result will appear
-->
</div>
<div id="script_div">
<!--Here your JSON script will come
<script src="http://search.twitter.com/search.json?callback=mycallback&q=hello">
</script>
-->
</div>
</body>
</html>