<div class="compile_hull" id="divKey">
<img src="../images/loading.gif" vspace="40" />
</div>
var key = function (id) {
$.ajax({
type: "POST",
url: '../rAjax/load_key.ashx',
data: { id: id },
success: function (msg) {
$("#divKey").html(msg);
} });
};<%@ WebHandler Language="C#" Class="load_key" %>using System;
using System.Web;public class load_key : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Request.ContentEncoding = System.Text.Encoding.UTF8;
string pid = context.Request["id"];
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Charset = "utf-8";
context.Response.ContentType = "text/plain";
context.Response.Write(test(pid));
} public bool IsReusable {
get {
return false;
}
}
public string test(string id)
{
return "hahahahahah" + id;
}}
这么写为什么不执行呢?
路径没错
$.ajax({
type: "POST",
dataType: "json",
url: '../rAjax/load_key.ashx',
data: { id: "id" },
success: function (msg) {
$("#divKey").html(msg);
} });
});
就这个应该没有问题了 我测试过可行..
$.ajax({
type: "POST",
url: '../rAjax/load_key.ashx',
data: { id: "id" },
success: function (msg) {
$("#divKey").html(msg);
} });
})