jquer ajax

 function SetValue() {
            var strCodeName = $("#MainContent_ddlFullNameAndFullName").val();
            if (strCodeName != "" && strCodeName.split('').length > 1) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: false,
                    url: "../GeneralFile/GeneralFile.ashx?PageName=COMPANYINFO&TRCODE_CO=" + strCodeName.split('')[1],
                    success: function (data) {
                        //返回的数据用data获取内容  

                        $("#MainContent_ddlCoClass").val(data[0].CO_CLASS);

                        $("#MainContent_ddlCustomsCode_input").val(data[0].CUSTOMS_CODE);
                        $("#MainContent_ddlCustomsCode").val(data[0].CUSTOMS_CODE);
                        $("#MainContent_ddlCustomsCode").attr('value', data[0].CUSTOMS_CODE);
                        $("#MainContent_ddlLawProperty").val(data[0].LAW_PROPERTY);
                        

                        $("#MainContent_txtCoAdress").val(data[0].CO_ADRESS);
                        $("#MainContent_txtCoAdress").attr('value', data[0].CO_ADRESS);
                        
                        $("#MainContent_txtEmsType").val(data[0].EMS_TYPE);

                        $("#MainContent_txtLawMan").val(data[0].LAW_MAN);
                        $("#MainContent_ddlBusiType").val(data[0].BUSI_TYPE);

                        $("#MainContent_txtLawManTel").val(data[0].LAW_MAN_TEL);
                        $("#MainContent_txtLawManMail").val(data[0].LAW_MAN_MAIL);

                        $("#MainContent_txtCopRange").val(data[0].COP_RANGE);
                        $("#MainContent_txtNote").val(data[0].NOTE);
                    },
                    error: function (err) {
                    }
                });
            }
        }
前台页面
namespace ENTERPRISE.GeneralFile
{
    /// <summary>
    /// GeneralFile 的摘要说明
    /// </summary>
    public class GeneralFile : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";
                string strPageName = HttpUtility.UrlDecode(context.Request.QueryString["PageName"]);
                if (strPageName == "COMPANYINFO")
                {
                    string strCompCode = HttpUtility.UrlDecode(context.Request.QueryString["TRCODE_CO"]);
                    //返回json序列
                    var enterpriseOinfohead = new EnterpriseEinfoHeadBodyPresenter(null);
                   // var SelectInfo = enterpriseOinfohead.SelectEInfo("TRADE_CO", strCompCode);
                    DataTable dt = enterpriseOinfohead.SelectCompanyInfo(strCompCode);
                    string jsonstr = string.Empty;
                    if(dt!=null)
                    {
                        jsonstr = JsonConvert.SerializeObject(dt, new DataTableConverter());
                    }
                    context.Response.Write(jsonstr);
                }
            }
            catch (Exception e)
            {
                string ss = e.Message;
            }
        }

        public bool IsReusable
        {
            get
            {
                return true;
            }
        }
    }
}
一般处理文件

 一般处理文件里访问数据库,如果要获取上下文,或sseion要

引用

System.Web.SessionState.IRequiresSessionState或IReadOnlySessionState 

有时不进入后台,注意js里的:  contentType: "application/json; charset=utf-8",

posted @ 2015-06-26 15:54  丁焕轩  阅读(256)  评论(0编辑  收藏  举报