<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "post",
dataType: "html",
url: "Handler1.ashx?a=1",
success: function (data, st) {
//var dt2 = jQuery.parseJSON(data);
var dt3 = eval('(' + data + ')');
//alert(dt2.teacher);
alert(dt3.teacher);
}
});
//var obj = jQuery.parseJSON('{"name":"John"}');
//alert(obj.name === "John");
})
</script>
发现jquery.parseJSON不是很好用,不推荐
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string start = "{\"title\":\"bt\",\"teacher\":\"ls \",\"time\":\"t\",\"student\":\"sdt\"}";
context.Response.Write(start);
}
public bool IsReusable
{
get
{
return false;
}
}
}
有什么错误,欢迎高手指点。
————————————————————————————————————————
结论:Jquery.parseJSON只支持标准的json格式