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,前端傳遞的參數,已經執行後臺方法返回值,都是成功的,不知道錯誤問題在哪,請高手幫忙解答,高分送上
添加回答
举报
0/150
提交
取消