ajax非同步呼叫

來源:互聯網
上載者:User

標籤:傳輸   驗證   max   ida   查看   ash   開啟   ==   mon   

服務端aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RA_PublicityOnLineInfo.aspx.cs" Inherits="HMFW.Web.Pages.SQJS.ResidentsAutonomy.RA_PublicityOnLineInfo" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title>網上公示資訊管理</title>    <script src="/Js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>    <script src="/Js/jquery-1.4.1.min.js" type="text/javascript"></script>    <script src="/Js/jquerytree/jquery.ztree.core-3.1.min.js" type="text/javascript"></script>    <link href="/Js/jquerytree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />    <script src="/Js/jquery.easyui.min.js" type="text/javascript"></script>    <script src="/Js/jquery.validate.js" type="text/javascript"></script>    <script src="/Js/jquery.form.js" type="text/javascript"></script>    <link href="/themes/default/easyui.css" rel="stylesheet" type="text/css" />    <link href="/themes/icon.css" rel="stylesheet" type="text/css" />    <script src="/Js/jquery-loadmask-0.4/jquery.loadmask.min.js" type="text/javascript"></script>    <link href="/Js/jquery-loadmask-0.4/jquery.loadmask.css" rel="stylesheet" type="text/css" />    <script src="/Js/edit.js" type="text/javascript"></script>    <script src="/Js/Common.js" type="text/javascript"></script>    <script src="/Js/Pages/SQJS/ResidentsAutonomy/RA_PublicityOnLineInfo.js" type="text/javascript"></script></head><body>    <form id="form1" runat="server">        <div>            <table id="T_Content" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"                class="content02">                <thead>                    <tr>                        <td colspan="4" class="content01bt">                            <span runat="server" id="acTitle">公示資訊</span>[<span runat="server" id="ActionInfo">新增</span>]                        </td>                    </tr>                </thead>                <tbody>                    <tr>                        <td nowrap="nowrap" width="13%" class="tdleft">                            <span class="red">*</span>公示類別:                        </td>                        <td nowrap="nowrap" width="37%" class="tdright">                            <asp:DropDownList ID="iTypeCode" runat="server" class="xlk180" ContentEditable="false">                                <asp:ListItem Value="1">選舉通知</asp:ListItem>                                <asp:ListItem Value="2">選民登記通知</asp:ListItem>                                <asp:ListItem Value="3">初步候選人資訊</asp:ListItem>                                <asp:ListItem Value="4">正式候選人資訊</asp:ListItem>                                <asp:ListItem Value="5">正式選舉內容和時間</asp:ListItem>                                <asp:ListItem Value="6">選舉結果公示</asp:ListItem>                            </asp:DropDownList>                              <asp:HiddenField runat="server" ID="siTypeCode" />                        </td>                        <td>是否公示:</td>                        <td>                            <asp:DropDownList ID="iOnLine" runat="server" class="xlk180" ContentEditable="false">                                <asp:ListItem Value="1">是</asp:ListItem>                                <asp:ListItem Value="0">否</asp:ListItem>                            </asp:DropDownList></td>                    </tr>                    <tr>                        <td nowrap="nowrap" class="tdleft"><span class="red">*</span>公示時間:                        </td>                        <td align="left" colspan="3">                            <asp:TextBox ID="txt_dPublictityStartTime" runat="server" onclick="WdatePicker()" class="srk80"></asp:TextBox>至<asp:TextBox ID="txt_dPublicityEndTime" runat="server" onclick="WdatePicker()" class="srk80"></asp:TextBox>                            <asp:HiddenField runat="server" ID="dPublictityStartTime" />                            <asp:HiddenField runat="server" ID="dPublicityEndTime" />                        </td>                    </tr>                    <tr>                        <td nowrap="nowrap" class="tdleft">                            <span class="red">*</span>公示內容:                        </td>                        <td nowrap="nowrap" class="tdright" colspan="3">                            <asp:TextBox ID="txt_sContent" runat="server" TextMode="MultiLine" class="Memo"></asp:TextBox>                            <asp:HiddenField runat="server" ID="sContent" />                        </td>                    </tr>                    <tr>                        <td nowrap="nowrap" class="tdleft">備忘:                        </td>                        <td nowrap="nowrap" class="tdright" colspan="3">                            <asp:TextBox ID="txt_sMemo" runat="server" TextMode="MultiLine" class="Memo"></asp:TextBox>                        </td>                    </tr>                </tbody>            </table>            <div class="tbError" id="LJRYerror">            </div>            <table width="100%" height="36" border="0" align="center" cellpadding="0" cellspacing="0">                <tr>                    <td align="center">                        <xhm:xhmButtionEasyUI ID="btn_Save" runat="server" IconTypeSelected="save" OnClientClick="Save(false);return false">儲存</xhm:xhmButtionEasyUI>                        <xhm:xhmButtionEasyUI ID="btn_SaveandAdd" runat="server" IconTypeSelected="save"                            OnClientClick="Save(true);return false;">儲存並新增</xhm:xhmButtionEasyUI>                        <xhm:xhmButtionEasyUI ID="btn_Return" runat="server" IconTypeSelected="back" OnClientClick="NBack(infoflag);return false;">返回</xhm:xhmButtionEasyUI>                    </td>                </tr>            </table>        </div>        <input type="hidden" id="hidID" runat="server" />    </form></body></html>
前端javascript

var infoflag = true; //是否須要給父頁面賦值  True 彈出框口 須要  False 開啟新頁面 不須要var handleurl = "/Handle/SQJS/ResidentsAutonomy/RA_PublicityOnLine.ashx"; //一般處理常式路徑//http://localhost:56248/Handle/SQJS/ResidentsAutonomy/RA_Candidate.ashxvar candidateHandleUrl = "/Handle/SQJS/ResidentsAutonomy/RA_Candidate.ashx";//確定初步候選人和確定正式候選人//http://localhost:56248/Handle/SQJS/ResidentsAutonomy/RA_ElectionProject.ashxvar electionProjectHandleUrl = "/Handle/SQJS/ResidentsAutonomy/RA_ElectionProject.ashx";//確認正式選舉內容和時間和確認選舉結果var type = getParameter("iType");//頁面狀態 編輯或者查看$(function () {    /******隱藏check 操作button*************/    if (type == "view") {        $("#btn_Save").hide();//儲存        $("#btn_SaveandAdd").hide();//儲存並新增        infoflag = false;//用於查看介面 返回        $("#ActionInfo").text("查看"); //把標識設定為查看        $("#T_Content .red").css({ "display": "none" });//查看去除必填選項標識        $("#T_Content").find("input").attr("disabled", "disabled");//input        $("#T_Content").find("textarea").attr("disabled", "disabled");//textarea        $("#iTypeCode").attr("disabled", "disabled");//公示類別        $("#iOnLine").attr("disabled", "disabled");//是否公示    }    var ID = GetID();    if (ID != "") {        Load(ID);    }    $("#iTypeCode").change(function () {        var checkValue = $("#iTypeCode").val();        var ID = GetID();//網上公示ID        var gProjectID = getParameter("gProjectID");//選舉項目ID        if (ID == "") {//相關公式資訊表:RA_Candidate RA_ElectionProject View_SQ_RA_ElectionProject_sPreliminaryConfirm View_SQ_RA_ElectionProject_sFormallyConfirm            switch (checkValue) {                case "3"://確定初步候選人【正式確覺得1】                    clearFields1();                    $.ajax({                        type: "POST", //用POST方式傳輸                        dataType: "json", //資料格式:JSON                        url: handleurl, //目標地址                        data: "action=preliminary&gID=" + gProjectID,                        cache: false,                        success: function (data) {                            //資料擷取完成,填充頁面據顯示                            if (data != null && data != "") {                                LoadData1(data);                            }                        },                        error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, errorThrown, ‘error‘); },                        beforeSend: function () {                        },                        complete: function () {                            $("hidLoad").val("1");                        }                    });                    break;                case "4":                    clearFields1();                    $.ajax({                        type: "POST", //用POST方式傳輸                        dataType: "json", //資料格式:JSON                        url: handleurl, //目標地址                        data: "action=formally&gID=" + gProjectID,                        cache: false,                        success: function (data) {                            //資料擷取完成,填充頁面據顯示                            if (data != null && data != "") {                                LoadData1(data);                            }                        },                        error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, errorThrown, ‘error‘); },                        beforeSend: function () {                        },                        complete: function () {                            $("hidLoad").val("1");                        }                    });                    break;                case "5":                    clearFields2();                    $.ajax({                        type: "POST", //用POST方式傳輸                        dataType: "json", //資料格式:JSON                        url: electionProjectHandleUrl, //目標地址                        data: "action=get&gID=" + gProjectID,                        cache: false,                        success: function (data) {                            //資料擷取完成,填充頁面據顯示                            if (data != null && data != "") {                                $("#txt_dPublictityStartTime").val(renderTime(data.dStartDate, true));//開始時間dPublictityStartTime                                $("#txt_dPublicityEndTime").val(renderTime(data.dEndDate, true));//結束時間                                $("#txt_sContent").val(data.sProjectContent);//公示內容                                $("#dPublictityStartTime").val(renderTime(data.dStartDate, true));//公示開始時間                                $("#dPublicityEndTime").val(renderTime(data.dEndDate, true));//公示結束時間                                $("#sContent").val(data.sProjectContent);//公示內容                                //$("#txt_sMemo").val(data.sMemo);//備忘                            }                        },                        error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, errorThrown, ‘error‘); },                        beforeSend: function () {                        },                        complete: function () {                            $("hidLoad").val("1");                        }                    });                    break;                case "6":                    clearFields2();                    $.ajax({                        type: "POST", //用POST方式傳輸                        dataType: "json", //資料格式:JSON                        url: handleurl, //目標地址                        data: "action=getivotecount&gID=" + gProjectID,                        cache: false,                        success: function (data) {                            //資料擷取完成,填充頁面據顯示                            if (data != null && data != "") {                                $("#txt_dPublictityStartTime").val(renderTime(data.dStartDate, true));//開始時間dPublictityStartTime                                $("#txt_dPublicityEndTime").val(renderTime(data.dEndDate, true));//結束時間                                $("#txt_sContent").val(data.iVoteCount);//公示內容:現場選舉 網上選舉 結果匯總                                $("#dPublictityStartTime").val(renderTime(data.dStartDate, true));//公示開始時間                                $("#dPublicityEndTime").val(renderTime(data.dEndDate, true));//公示結束時間                                $("#sContent").val(data.iVoteCount);//公示內容                                //$("#txt_sMemo").val(data.sMemo);//備忘                            }                        },                        error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, errorThrown, ‘error‘); },                        beforeSend: function () {                        },                        complete: function () {                            $("hidLoad").val("1");                        }                    });                    break;                default:                    clearFields3();                    break;            }        } else if (ID != "") {//RA_PublicityOnLine表            Load(ID);        }    });});function Load(ID) {    $.ajax({        type: "POST", //用POST方式傳輸        dataType: "json", //資料格式:JSON        url: handleurl, //目標地址        data: "action=get&gID=" + ID,        cache: false,        success: function (data) {            //資料擷取完成,填充頁面據顯示            if (data != null && data != "") {                LoadData(data);                IsPublicityOnLine(data);//頁面載入 設定屬性值            }        },        error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, errorThrown, ‘error‘); },        beforeSend: function () {        },        complete: function () {            $("hidLoad").val("1");        }    });}function IsPublicityOnLine(data) {    $("#iTypeCode").attr("disabled", "disabled");    var iTypeCode = data.iTypeCode;    switch (iTypeCode) {        case 3:            $("#txt_sContent").attr("disabled", "disabled");//正式選舉內容            break;        case 4:            $("#txt_sContent").attr("disabled", "disabled");//正式選舉內容            break;        case 5:            clearFields2();        case 6:            clearFields2();            break;        default:            break;    }}function LoadData(data) {    SetInputValue(data);    $("#txt_dPublictityStartTime").val(renderTime(data.dPublictityStartTime, true));//公示開始時間    $("#txt_dPublicityEndTime").val(renderTime(data.dPublicityEndTime, true));//公示結束時間    $("#dPublicityEndTime").val(renderTime(data.dPublicityEndTime, true));//公示結束時間    $("#dPublictityStartTime").val(renderTime(data.dPublictityStartTime, true));//公示開始時間    $("#sContent").val(data.sContent);    $("#siTypeCode").val(data.iTypeCode);}function LoadData1(data) {    $("#txt_sContent").val(data.sCandidatePeopNames);//公示內容    $("#sContent").val(data.sCandidatePeopNames);//公示內容    //$("#txt_sMemo").val(data.sMemo);//備忘}function CheckInput() {    var result = $("#form1").validate({        rules: {            txt_dPublictityStartTime: {                required: true,                dateISO: true            },            txt_dPublicityEndTime: {                required: true,                dateISO: true            },            txt_sContent: {                required: true,                maxlength: 500            }        }    });    return result.form();};function CheckInput1(iTypeCode) {    var result;    if (GetID() == "") {        var gProjectID = getParameter("gProjectID");//選舉項目ID        $.ajax({            type: "POST",            url: handleurl,            data: "action=ismanypublicityonline&gProjectID=" + gProjectID + "&iCode=" + iTypeCode,            dataType: "json",            async: false,            error: function (XmlHttpRequest, textStatus, errorThrown) { $.messager.alert(‘錯誤‘, XmlHttpRequest.responseText, ‘error‘); },            success: function (returnJsonValue) {                if (returnJsonValue.result == false) {                    $.messager.alert(‘資訊‘, returnJsonValue.data, ‘info‘);                    result = returnJsonValue.result.toString();                }                //clearFields(); //清空介面和隱藏欄位ID            },            beforeSend: function () {            },            complete: function () {            }        });    }    return result;}function Save(isDoNew) {    var iTypeCode = $("#iTypeCode").val();//網上公示類型    var action = "add";    var queryString = $(‘#T_Content :input‘).fieldSerialize();    if (GetID() != "") {        action = "edit";        iTypeCode = $("#siTypeCode").val();    }    var sTypeName = "";//公示類別    if (iTypeCode != "") {//公示類別        sTypeName = $("#iTypeCode").find("option:selected").text();    }    queryString += "&sTypeName=" + sTypeName;    if (CheckInput1(iTypeCode) == "false") {//先驗證同一個項目不同意有多個同樣類別公式! 後驗證基礎資訊        return false;    }    var data = "action=" + action + "&gID=" + GetID() + "&" + queryString + "&gProjectID=" + getParameter("gProjectID"); //    Save_1(isDoNew, handleurl, data, infoflag);}function clearFields2() {    //////////////$("#txt_dPublictityStartTime").attr("disabled", "disabled");//開始時間    //////////////$("#txt_dPublicityEndTime").attr("disabled", "disabled");//結束時間    $("#txt_sContent").attr("disabled", "disabled");//正式選舉內容}//設定介面屬性值 確定正式選舉內容和時間function clearFields1() {    //////////$("#txt_dPublictityStartTime").attr("disabled", false);//開始時間    //////////$("#txt_dPublicityEndTime").attr("disabled", false);//結束時間    $("#txt_sContent").attr("disabled", "disabled");}function clearFields3() {    $("#iTypeCode").attr("disabled", false);//    //////////$("#txt_dPublictityStartTime").attr("disabled", false);//    //////////$("#txt_dPublicityEndTime").attr("disabled", false);//    $("#txt_sContent").attr("disabled", false);//正式選舉內容    SetID(""); //清空ID的隱藏欄位    $("#txt_dPublictityStartTime").val("");    $("#txt_dPublicityEndTime").val("");    $("#sContent").val("");    $("#txt_sContent").val("");    $("#txt_sMemo").val("");    $("#iOnLine").val("1");}function clearFields() {    $("#iTypeCode").attr("disabled", false);//    ////////$("#txt_dPublictityStartTime").attr("disabled", false);//    ////////$("#txt_dPublicityEndTime").attr("disabled", false);//    $("#txt_sContent").attr("disabled", false);//正式選舉內容    SetID(""); //清空ID的隱藏欄位    $(‘#T_Content :input‘).clearFields(); //清空介面    $("#sContent").val("");    //$("#siTypeCode").val("");    $("#iTypeCode").val("1");    $("#iOnLine").val("1");}

ajax非同步呼叫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.