当前位置: 代码迷 >> ASP.NET >> 小弟我这么写为什么不执行呢?哪错了呢
  详细解决方案

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

热度:1877   发布时间:2013-02-26 00:00:00.0
我这么写为什么不执行呢?哪错了呢?
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")(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")(msg);                }            });        });
------解决方案--------------------------------------------------------
仓老师.... jquery 的ajax请求可以不写请求类型,但是一定要写返回类型
JScript code
$(function(){            $.ajax({                type: "POST",                dataType: "json",                url: '../rAjax/load_key.ashx',                data: { id: "id" },                success: function (msg) {                    $("#divKey")(msg);                }            });        });
  相关解决方案