您的位置:首页 > Web前端 > JQuery

【javascript】jquery jsonp跨越请求

2014-06-20 10:30 309 查看
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("input[type=button]").click(function() {
//begin
$.ajax({
url: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='+$("#keywords").val(),
type: 'get',
dataType: 'jsonp',
jsonp:"callback",
jsonpCallback:"aa",
})
// end

});

});
function aa(data){
alert(data.results['url'])

}
</script>
</head>
<body>
<input type="text" name='keywords' id="keywords"/><br/>
<input type="button"  value="查询"/>
<p id="content"></p>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: