Ajax asynchronous invocation

Source: Internet
Author: User

Service-side ASPX

<%@ page language= "C #" autoeventwireup= "true" codebehind= "RA_PublicityOnLineInfo.aspx.cs" inherits= "HMFW. Web.Pages.SQJS.ResidentsAutonomy.RA_PublicityOnLineInfo "%><! DOCTYPE html>Front-end JavaScript

var infoflag = true; Is it necessary to assign a value to the parent page if the popup port requires False to open a new page without var handleurl = "/handle/sqjs/residentsautonomy/ra_publicityonline.ashx"; Generic handler path//http://localhost:56248/handle/sqjs/residentsautonomy/ra_candidate.ashxvar CANDIDATEHANDLEURL = "/ Handle/sqjs/residentsautonomy/ra_candidate.ashx ";//Identify the preliminary candidate and determine the formal candidate//http://localhost:56248/handle/sqjs/ Residentsautonomy/ra_electionproject.ashxvar Electionprojecthandleurl = "/handle/sqjs/residentsautonomy/ra_ Electionproject.ashx ";//confirm the official election contents and time and confirm the election result var type = GetParameter (" IType ");//page state edit or view $ (function () {/****** Hides the check Operation button*************/if (type = = "View") {$ ("#btn_Save"). Hide ();//Save $ ("#btn_SaveandAdd"). Hide ();//save and add Infoflag = false;//for viewing interface return $ ("#ActionInfo"). Text ("View"); Set the identity to view $ ("#T_Content. Red"). CSS ({"Display": "None"});//view remove required option to identify $ ("#T_Content"). Find ("Input"). attr (" Disabled "," disabled ");//input $ (" #T_Content "). Find (" textarea "). attr (" Disabled "," disabled ");//TextArea $ ("#iTypeCode"). attr ("Disabled", "disabled");//Public Announcement category $ ("#iOnLine"). attr ("Disabled", "disabled");    Announcement} var ID = GetID ();    if (id! = "") {Load (ID);        } $ ("#iTypeCode"). Change (function () {var CheckValue = $ ("#iTypeCode"). Val (); var id = GetID ();//Online Publicity id var gprojectid = getparameter ("Gprojectid");//Election item ID if (id = = "") {//Related Formula information table: Ra_c Andidate Ra_electionproject view_sq_ra_electionproject_spreliminaryconfirm view_sq_ra_electionproject_ Sformallyconfirm switch (checkvalue) {case "3"://Confirm initial candidate "officially feel 1" clearfields                    1 ();                        $.ajax ({type: "POST",//Post transfer dataType: "JSON",//Data format: JSON                        Url:handleurl,//Destination address data: "action=preliminary&gid=" + Gprojectid,                            Cache:false, Success:function (data) {Data get completed, populate page according to if (data! = NULL && Data! = "") {Loadd                            ATA1 (data); }}, Error:function (XMLHttpRequest, Textstatus, Errorthrown) {$.messager. Alert (' Wrong ', Errorthrown, ' error ');  }, Beforesend:function () {}, Complete:function ()                        {$ ("Hidload"). Val ("1");                    }                    });                Break                    Case "4": clearFields1 ();                        $.ajax ({type: "POST",//Post transfer dataType: "JSON",//Data format: JSON                        Url:handleurl,//Destination address data: "action=formally&gid=" + Gprojectid, Cache:false, Success:function (data) {//Get completed, populate pageIt is shown if (data! = NULL && Data! = "") {LoadData1 (data);  }}, Error:function (XMLHttpRequest, Textstatus,                        Errorthrown) {$.messager.alert (' error ', Errorthrown, ' Error ');}, Beforesend:function () {                        }, Complete:function () {$ ("Hidload"). Val ("1");                    }                    });                Break                    Case "5": ClearFields2 ();                        $.ajax ({type: "POST",//Post transfer dataType: "JSON",//Data format: JSON                        Url:electionprojecthandleurl,//Destination address data: "action=get&gid=" + Gprojectid, Cache:false, Success:function (data) {///get completed, populate the page according to Shown                            if (data! = NULL && Data! = "") {$ ("#txt_dPublictitySt Arttime "). Val (Rendertime (Data.dstartdate, True));//Start time Dpublictitystarttime $ (" #txt_dPublic Ityendtime "). Val (Rendertime (Data.denddate, True));//End Time $ (" #txt_sContent "). Val (Data.sproje ctcontent)///Disclosure Content $ ("#dPublictityStartTime"). Val (Rendertime (Data.dstartdate, True));//When the announcement begins                                Between $ ("#dPublicityEndTime"). Val (Rendertime (Data.denddate, True));//Announcement End time $ ("#sContent"). Val (data.sprojectcontent);//announcement Content//$ ("#txt_sMemo"). Val (Data.smem o);//Remarks}}, Error:function (XMLHttpRequest, Tex                        Tstatus, Errorthrown) {$.messager.alert (' error ', Errorthrown, ' Error ');}, Beforesend:function () { }, Complete:function () {$ ("Hidload"). Val ("1");                    }                    });                Break                    Case "6": ClearFields2 ();                        $.ajax ({type: "POST",//Post transfer dataType: "JSON",//Data format: JSON                        Url:handleurl,//Destination address data: "action=getivotecount&gid=" + Gprojectid,                            Cache:false, Success:function (data) {///Get completed, populate page according to display if (data! = NULL && Data! = "") {$ ("#txt_dPublictityStartT IME "). Val (Rendertime (Data.dstartdate, True));//Start time Dpublictitystarttime $ (" #txt_dPublicityE Ndtime "). Val (Rendertime (Data.denddate, True));//End Time $ (" #txt_sContent "). Val (data.ivotecount );//announcement content: On-site election onlineSummary of election results $ ("#dPublictityStartTime"). Val (Rendertime (Data.dstartdate, True));//Announcement Start time                                $ ("#dPublicityEndTime"). Val (Rendertime (Data.denddate, True));//Announcement End time                            $ ("#sContent"). Val (data.ivotecount);//Public Announcement//$ ("#txt_sMemo"). Val (Data.smemo);//Remarks }}, Error:function (XMLHttpRequest, Textstatus, Errort                        Hrown) {$.messager.alert (' error ', Errorthrown, ' Error ');}, Beforesend:function () {                        }, Complete:function () {$ ("Hidload"). Val ("1");                    }                    });                Break                    DEFAULT:CLEARFIELDS3 ();            Break        }} else if (id! = "") {//ra_publicityonline table Load (ID); }    });}); function Load (ID) {   $.ajax ({type: "POST",//Transmit dataType with post: "JSON",//Data format: JSON Url:handleurl,//Destination address dat            A: "action=get&gid=" + ID, Cache:false, success:function (data) {//Get completed, populate page according to display                if (data! = NULL && Data! = "") {LoadData (data); Ispublicityonline (data);//Page Loading setting property value}}, Error:function (XMLHttpRequest, Textstatus, Errorthrow  N) {$.messager.alert (' error ', 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");//The official election content break;        Case 4: $ ("#txt_sContent"). attr ("Disabled", "disabled");//The official election content break;      Case 5:      ClearFields2 ();            Case 6:clearfields2 ();        Break    Default:break;    }}function LoadData (data) {setinputvalue (data); $ ("#txt_dPublictityStartTime"). Val (Rendertime (Data.dpublictitystarttime, True));//Announcement Start time $ ("#txt_ Dpublicityendtime "). Val (Rendertime (Data.dpublicityendtime, True));//Announcement End time $ (" #dPublicityEndTime "). Val ( Rendertime (Data.dpublicityendtime, True));//Announcement End time $ ("#dPublictityStartTime"). Val (Rendertime (    Data.dpublictitystarttime, True));//Announcement Start time $ ("#sContent"). Val (data.scontent); $ ("#siTypeCode"). Val (Data.itypecode);} function LoadData1 (data) {$ ("#txt_sContent"). Val (data.scandidatepeopnames);//Disclosure Contents $ ("#sContent"). Val ( Data.scandidatepeopnames);////$ ("#txt_sMemo"). Val (Data.smemo);//Note}function checkinput () {var result = $ ("#for M1 "). Validate ({rules: {txt_dpublictitystarttime: {required:true, Datei So: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");//Election Project ID $.ajax ({type: "POST", Url:handleurl, data: "action=ismanypublicityonline&gprojectid=" + Gprojectid + "&icode=" + Itypecode, DataType: "JSON", Async:false, Error:function (XMLHttpRequest, Textstatus, E Rrorthrown) {$.messager.alert (' error ', Xmlhttprequest.responsetext, ' Error ');}, Success:function (returnjsonval UE) {if (Returnjsonvalue.result = = False) {$.messager.alert (' info ', returnjsonvalue.data                    , ' info ');                result = ReturnJsonValue.result.toString (); }//cleaRfields ();            Clear the interface and hide the domain ID}, beforesend:function () {}, Complete:function () {    }        }); } return result;    function Save (isdonew) {var Itypecode = $ ("#iTypeCode"). Val ();//Online publicity type var action = "Add";    var queryString = $ (' #T_Content: Input '). Fieldserialize ();        if (GetID () = "") {action = "edit";    Itypecode = $ ("#siTypeCode"). Val (); } var stypename = "";//Public Announcement category if (Itypecode! = ") {//Public announcement Category Stypename = $ (" #iTypeCode "). Find (" option:selected ").    Text ();    } queryString + = "&stypename=" + stypename;    if (CHECKINPUT1 (itypecode) = = "false") {//First verify that the same item does not agree to have multiple same category formulas! After verifying the underlying information return false; } var data = "action=" + action + "&gid=" + GetID () + "&" + queryString + "&gprojectid=" + getparameter ("GP Rojectid "); Save_1 (Isdonew, Handleurl, data, Infoflag);} function ClearFields2 () {//////////////$ ("#txt_dPublictityStartTime"). attr ("Disabled", "disabled");//Start//////////////$ ("#txt_dPublicityEndTime"). attr ("Disabled", "disabled");//End Time $ ("#txt_sContent"). attr ("Disabled "Disabled");//formal election content}//set the interface property value to determine the formal election content and time function clearFields1 () {//////////$ ("#txt_dPublictityStartTime"). attr ("Disabled", false);//Start Time//////////$ ("#txt_dPublicityEndTime"). attr ("disabled", false);//End Time $ ("#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);//formal election content SetID (" ");    Empties the ID of the hidden domain $ ("#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 ("Di SabLed ", false);//////////$ (" #txt_dPublicityEndTime "). attr (" disabled ", false);/$ (" #txt_sContent "). attr (" Disabled ", FALSE);//formal election content SetID (""); Empty the ID of the hidden domain $ (' #T_Content: Input '). Clearfields ();    Empty the interface $ ("#sContent"). Val ("");    $ ("#siTypeCode"). Val ("");    $ ("#iTypeCode"). Val ("1"); $ ("#iOnLine"). Val ("1");}

Ajax asynchronous invocation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.