首页 新闻 会员 周边 捐助

jquery ajax 問題請教

0
悬赏园豆:100 [已解决问题] 解决于 2010-10-15 15:05

jquery ajax 問題請教,請前輩高人幫忙解答

使用jQuery jquery-1.4.2.min.js  官方JS包

平時通過 AJAX  post 到 ashx頁面來訪問後臺  CS是可以正常執行的。

 

但是今天在使用AJAX的時候,有成功 post到 ashx 頁面,有DEBUG跟蹤到成功context.Response.Write(result);

但是回到頁面上,jquery 報錯錯誤:

行: 1936
錯誤: 未指定的錯誤。

jquery 報錯的代碼: 

handle: function( event ) 下面的

  var ret = handleObj.handler.apply( this, arguments );

我的前端AJAX代碼:

$.ajax({       
                type: "post",
                async: false,
                processData: false,   
                dataType: "xml",
                url: "/ewfv3/web/def/Inc/ashx/UCLCreateButton.ashx?modeType=xml&MothodName=Sign",
                contentType: "text/xml", 
                data: strXml,  
                error: function(xhr, textStatus, thrownError)
                {
                    alert("Error:" + xhr.responseText);
                },             
                success: function(x)
                {
                     if(x.text==null)
                     {
                           alert(x);
                           retValue= x.documentElement.textContent;
                     }
                     else
                     {
                           retValue = x.text;  
                     }
                 }
                
            });  

ashx文件代碼:

<%@ WebHandler Language="C#" class="UCLCreateButton" %>

using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;
using System.Data.OracleClient;
using System.Text;
using System.Xml;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


public class UCLCreateButton : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        if (System.Web.HttpContext.Current.Request["modeType"] != null)
        {
            if (System.Web.HttpContext.Current.Request["modeType"].ToString() == "xml")
            {
                context.Response.ContentType = "application/xml";
            }
        }
        else
        {
            context.Response.ContentType = "text/plain";
        }

        //System.Diagnostics.Debug.Assert(false);
       
        context.Response.Buffer = true;
        context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";

        string result = "", p_MothodName = "";
       
        if (context.Request.Params["MothodName"] != null)
        {
            p_MothodName = context.Request.Params["MothodName"];
            result = Main(p_MothodName, context);
        }
        else
        {
            context.Response.Write(result);
            return;
        }

        context.Response.Write(result);
       
    }

    private string Main(string p_MothodName, HttpContext context)
    {
        switch (p_MothodName)
        {
            case "Sign":
                {
                    return "<RESULT>" + new BusEWF.BusEntry().LoadMethod("Sign", QueryXmlDocu(), context) + "</RESULT>";
                }
            default:
                return "";
        }
    }

    private System.Xml.XmlDocument QueryXmlDocu()
    {
        System.Xml.XmlDocument xd2 = new System.Xml.XmlDocument();
        if (System.Web.HttpContext.Current.Request["modeType"] == "xml")
        {
            try
            {
                System.Web.HttpContext.Current.Response.ContentType = "application/xml";
                xd2.Load(System.Web.HttpContext.Current.Request.InputStream);             
                return xd2;
            }
            catch (Exception ex)
            {
                System.Web.HttpContext.Current.Response.ContentType = "text/plain";           
                System.Web.HttpContext.Current.Response.Write(ex.Message);
                System.Web.HttpContext.Current.Response.End();
                return new System.Xml.XmlDocument();
            }

        }
        else
            return new System.Xml.XmlDocument();
    }
   
       
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}

 

備註:我有跟蹤debug,前端傳遞的參數,已經執行後臺方法返回值,都是成功的,不知道錯誤問題在哪,請高手幫忙解答,高分送上

jcewfpdf的主页 jcewfpdf | 初学一级 | 园豆:100
提问于:2010-10-14 16:40
< >
分享
最佳答案
0

我试了一下好像是可以的啊。

不过new BusEWF.BusEntry().LoadMethod("Sign", QueryXmlDocu(), context)这句我改成固定字符串了,

因为没有类型BusEWF相关信息。

收获园豆:100
wang_yb | 老鸟四级 |园豆:4893 | 2010-10-15 09:59
雖然沒有幫忙解決,但是你都肯去試,分子給你把, 我使用 firefox執行,無異常,今天我用IE試也沒問題了,沒做任何改動。納悶中...
jcewfpdf | 园豆:100 (初学一级) | 2010-10-15 15:06
其他回答(1)
0

success回调有进入吗?

Gray Zhang | 园豆:17610 (专家六级) | 2010-10-14 16:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册