请教大家一个问题,jquery+ajax,往httphandlers(也就是后台)传递的 data: {"school" :"南京大学"} 参数,后台怎样才能接
请教大家一个问题,jquery+ajax,往httphandlers(也就是后台)传递的 data: {"school" :"南京大学"} 参数,后台怎样才能接到呢?
注意:数据传送方式为post (get的话,很简单就取到了。)
1,web侧的代码:
$(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" 对应的值是 "南京大学" ???? } }}