【javascript】jquery jsonp跨越请求

时间:2025-04-17 19:04:49
 <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>