【javascript】jquery jsonp跨越请求
1 <html> 2 <head> 3 <meta charset="utf-8"> 4 <title></title> 5 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"> 6 </script> 7 <script type="text/javascript"> 8 $(document).ready(function() { 9 $("input[type=button]").click(function() { 10 //begin 11 $.ajax({ 12 url: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='+$("#keywords").val(), 13 type: 'get', 14 dataType: 'jsonp', 15 jsonp:"callback", 16 jsonpCallback:"aa", 17 }) 18 // end 19 20 }); 21 22 }); 23 function aa(data){ 24 alert(data.results['url']) 25 26 } 27 </script> 28 </head> 29 <body> 30 <input type="text" name='keywords' id="keywords"/><br/> 31 <input type="button" value="查询"/> 32 <p id="content"></p> 33 </body> 34 </html>