首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

小弟我这么写为什么不执行呢?哪错了呢

2012-01-14 
我这么写为什么不执行呢?哪错了呢?HTML codediv classcompile_hull iddivKeyimg src../images/

我这么写为什么不执行呢?哪错了呢?

HTML code
    <div class="compile_hull" id="divKey">                 <img src="../images/loading.gif" vspace="40" />                    </div>

JScript code
    var key = function (id) {            $.ajax({                type: "POST",                url: '../rAjax/load_key.ashx',                data: { id: id },                success: function (msg) {                    $("#divKey").html(msg);                }            });        };


C# code
<%@ 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;    }}


这么写为什么不执行呢?

[解决办法]
JScript code
$(function(){            $.ajax({                type: "POST",                url: '../rAjax/load_key.ashx',                data: { id: "id" },                success: function (msg) {                    $("#divKey").html(msg);                }            });        });
[解决办法]
仓老师.... jquery 的ajax请求可以不写请求类型,但是一定要写返回类型
JScript code
$(function(){            $.ajax({                type: "POST",                dataType: "json",                url: '../rAjax/load_key.ashx',                data: { id: "id" },                success: function (msg) {                    $("#divKey").html(msg);                }            });        }); 

热点排行