proname = $("#txt_proName").val();
    $.ajax({
        type: "post",
        url: "../FormHandler/ItemAllHandler.ashx",
        data: { proname: proname, meth: "GetZhaobggJd" },
        datatype: "text",
        beforeSend: function() {
            $('div#lbl_rpt_nozbgg').show('normal');
        },
        success: function(msg) {
            alert(msg);//得不到值
        },
        complete: function() {
            $('div#lbl_rpt_nozbgg').hide('normal');
        }
    });
//程序已经请求到后台这里了,设置断点得到异常   ProjectAndEntBll projectentbll = new ProjectAndEntBll();
            DataSet ds = projectentbll.GetZhaobggJd();
            if (ds != null)
            {
                context.Response.Write("true");
                try
                {
                    context.Response.End();//这里出异常
                }
                catch (Exception e) {
                    e.ToString();// e = {由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值。}
                }
            }
            else 
            {
                context.Response.Write("false");
                context.Response.End();
            }
如果不要context.Response.End();还是返回不到值。请问什么原因,怎么解决?

解决方案 »

  1.   

    不要try catch
    直接 response.write()
    response.end();
    juery参数
    data:{"username":$("#txtname").val,"pwd":};
    success:function(msg)
    {
    //调试下用alert typeof
    }
      

  2.   

    路径对的,我下断点,已经进入到后台,不try试过,不用context.Response.End();也试过。
      

  3.   

            success: function(msg) {
                alert(msg);//得不到值
            },
    这句走到了吗,没有alert还是alert null或是undefine?
    建议以后AJAX都加上错误Calback
            error: function(error) {
                alert(error);//error信息
            },
      

  4.   


    根本就不alert不弹出提示框,不知道为什么运行不到那句去
    好明天去加上error: function(error) { 
                alert(error);//error信息 
            }这个
      

  5.   

    调试能否得到这两个参数?
     data: { proname: proname, meth: "GetZhaobggJd" },
      

  6.   


    改成这样试试:
    if (ds != null)
    {
       Response.Clear();
       Response.Write("true");
       Response.End();

    else 
    {
       Response.Clear();
       Response.Write("false");
       Response.End();
    }
      

  7.   

    改成这样试试:
    C# codeif (ds!=null)
    {
       Response.Clear();
       Response.Write("true");
       Response.End();
    }else 
    {
       Response.Clear();
       Response.Write("false");
       Response.End();
    }
    [/Quote]
    这样行了,但是有时还是获取不到,有时快,有时要等会才能获取到···
      

  8.   

    ajax本来就很难调试 等大牛们来吧
      

  9.   

    加上一句Response.Flush()呢。
    在END之前
      

  10.   

    还有。如果你不想异步
    那么就在$.ajax里讲异步的参数设置为false