<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;
    }}
这么写为什么不执行呢?

解决方案 »

  1.   

    本帖最后由 Sandy945 于 2011-12-01 09:26:10 编辑
      

  2.   

     url: '../rAjax/load_key.ashx',  可能是这个路径出了问题,把断点打在ashx文件里面,调试看看能否跳转进去   .
      

  3.   

    还不执行。如果执行的话应该返回内个字符串才对啊什么都不返回还不进入ashx断点
    路径没错
      

  4.   

    dataType: "json",  请求里面加上这一句
      

  5.   

    你在hard中使用upload调用这个方法你看行不行
      

  6.   

    仓老师.... jquery 的ajax请求可以不写请求类型,但是一定要写返回类型$(function(){
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: '../rAjax/load_key.ashx',
                    data: { id: "id" },
                    success: function (msg) {
                        $("#divKey").html(msg);
                    }            });
            });
    就这个应该没有问题了 我测试过可行..
      

  7.   

    $(document).ready(function () {
    $.ajax({
    type: "POST",
    url: '../rAjax/load_key.ashx',
    data: { id: "id" },
    success: function (msg) {
    $("#divKey").html(msg);
    }     });
    })
      

  8.   

    dataType: "json",   这个木必要成json, text也行,根据情况