日期:2014-05-16 浏览次数:20746 次
$(function(){
$.ajax ({
url : "MyJsonHandler/student.json", // JSON数据的地址
type: 'post', // 数据传送方式
dataType: 'json', // 数据类型
data: {"school" :"南京大学"},
contentType: 'application/json',
success : function( data, textStatus,jqXHR ) {
alert("success");
},
// 返回结果为失败
error : function(jqXHR, textStatus, errorThrown) {
alert('error');
}
});
});
</script>
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace MyHandlers
{
public class MyJsonHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
// 如何取得 "school" 对应的值是 "南京大学" ????
}
}
}