<
html
xmlns="http://www.w3.org/1999/xhtml">
head
>
title
></
>
script
src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></
>
type="text/javascript">
$().ready(function () {
$('#selectNum').change(function () {
var idValue = $(this).val();
var show = $('#show');
$.ajax({
url: 'Server.aspx',
type: 'POST',
data: { id: idValue },
//调小超时时间会引起异常
timeout: 3000,
//请求成功后触发
success: function (data) { show.append('success invoke!' + data+'<
br
/>'); },
//请求失败遇到异常触发
error: function (xhr,errorInfo,ex) { show.append('error invoke!errorInfo:' + errorInfo+'<
//完成请求后触发。即在success或error触发后触发
complete: function (xhr,status) { show.append('complete invoke! status:' + status+'<
//发送请求前触发
beforeSend: function (xhr) {
//可以设置自定义标头
xhr.setRequestHeader('Content-Type','application/xml;charset=utf-8');
show.append('beforeSend invoke!' +'<
/>');
},
//是否使用异步发送
async: true
})
});
})
</
>
>
body
>
select
id="selectNum">
<
option
value="0">--Select--</
>
value="1">1</
>
value="2">2</
>
value="3">3</
>
>
div
id="show"></
>
>
>