跨域求代码哪里错了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>bing search无标题文档</title> <style type="text/css"> body{ background-color:#333; } .bjdiv{ background-image:url(river.jpg); width:1228px; height:690px; margin:0 auto; position:relative; } .logo{ background-image:url(logo.png); width:107px; height:53px; float:left; margin:-4px 18px 0 0; } form{ float:left; background-color:#fff; padding:5px; } .search-input-text{ border:0; float:left; width:350px; height:25px; line-height:25px; outline:none; } .search-input-button{ border:0; background-image:url(search-button.png); width:29px; height:29px; float:left; } .searchbox{ position:absolute; top:200px; left:300px; } .suggest{ width:388px; background-color:#fff; border:1px solid #999; } .suggest ul{ list-style:none; margin:0; padding:0; } .suggest ul li{ padding:3px; font-size:14px; line-height:25px; cursor:pointer; } .suggest ul li:hover{ text-decoration:underline; background-color:#e5e5e5; } </style> </head> <body> <div class="bjdiv"> <div class="searchbox"> <div class="logo"></div> <form id="search-form"> <input type="text" class="search-input-text" id="search-input"/> <input type="submit" value="" class="search-input-button"/> </form> </div> </div> <div class="suggest" id="search-suggest" style="display:none"> <ul id="search-result"> <li>搜索结果1</li> <li>搜索结果2</li> </ul> </div> <script src="jquery-1.9.1.js"></script> <script type="text/javascript"> $('#search-input').bind('keyup',function(){ var searchText = $('search-input').val(); /* $.get('http://api.bing.com/qsonhs.aspx?q='+searchText,function(d){ var d = d.AS.Results[0].Suggests; console.log(d); var html = ''; for(var i=0;i<d.length;i++){ html+='<li>'+d[i].Txt+'</li>'; } $('search-result').html(html); $('#search-suggest').show().css({ top:$('#search-form').offset().top+$('#search-form').outerHeight(), left:$('#search-form').offset().left, position:'absolute' }); },'json');*/ if(searchText) { $.ajax({ type:"GET", url:"http://api.bing.com/qsonhs.aspx?type=cb&q="+searchText, dataType:'jsonp', jsonp:'cb', success: function(d) { var d = d.AS.Results[0].Suggests; var html = ''; for(var i = 0; i < d.length; i++) { html += '<li>'+d[i].Txt+'</li>'; } $('#search-result').html(html); $('#search-suggest').show().css({ top:$('#search-form').offset().top+$('#search-form').outerHeight(), left:$('#search-form').offset().left, position:'absolute' }); }, error: function() { console.log("error"); } }); } else { $('#search-suggest').hide(); } }); $(document).bind('click',function(){ $('#search-suggest').hide(); }); </script> </body> </html>
关于跨域问题的代码是从别的地方找的,但是运行后还是没有效果,求是哪里出错了,该怎么修改?