日期:2014-05-16 浏览次数:20786 次
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="css/高级Ajax.css" type="text/css" />
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript">
$(function () {
//收获JSONP数据,跨域获取数据
var $ajaxForm = $('#ajax-form'),
$response = $('#response');
$ajaxForm.bind('submit', function (event) {
event.preventDefault();
$.ajax({
url: 'http://api.jquery.com/jsonp/',
dataType: 'jsonp',
data: {
title: $('#title').val()
},
jsonp: 'callback',
success: function (data) {
alert(data);
}
});
});
});
</script>
<form id="ajax-form" action="http://api.jquery.com/" method="get">
<fieldset>
<div class="text">
<label for="title">Search</label>
<input type="text" id="title" name="s" />
</div>
<div class="actions">
<button type="submit">Request</button>
</div>
</fieldset>
&nb