資源描述:
《基于c#的ajax 功能實現(xiàn) 源代碼》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在行業(yè)資料-天天文庫。
1、這是本人在學校時照老師的要求做的最簡單的ajax功能,不好勿噴。這代碼主要分為html代碼和cs后臺代碼,和數(shù)據(jù)庫連接的功能我就沒發(fā)數(shù)據(jù)庫了,都是簡單的數(shù)據(jù)庫。(基于C#的ajax功能實現(xiàn)代碼。),僅供參考。1、地區(qū)信息查詢varXMLHttpRequest;varrequestType="";functiongetXMLH
2、ttpRequest(){if(window.ActiveXObject){XMLHttpRequest=newActiveXObject("Microsoft.XMLHTTP");}elseif(window.XMLHttpRequest){XMLHttpRequest=newXMLHttpRequest();}}functionsendRquest(request){requestType=request;getXMLHttpRequest();XMLHttpRequest.onreadystatechange=stateChange;XMLH
3、ttpRequest.open("GET","XMLFile2.xml");XMLHttpRequest.send(null);}functionstateChange(){if(XMLHttpRequest.readyState==4){if(XMLHttpRequest.status==200){if(requestType=="north"){listNorthStates();}elseif(requestType=="all"){listAllStates();}elseif(requestType=="south"){listSouth
4、States();}elseif(requestType=="east"){listEastStates();}elseif(requestType=="west"){listWestStates();}}}}varnorthStates;varsouthStates;vareastStates;varwestStates;varallStates;functionlistNorthStates(){varxmlDOC=XMLHttpRequest.responseXML;varnorthNode=xmlDOC.getElementsByTagNa
5、me("north")[0];northStates=northNode.getElementsByTagName("state");output("北à?à部?州Y名?",northStates);}functionlistSouthStates(){varxmlDOC=XMLHttpRequest.responseXML;varsouthNode=xmlDOC.getElementsByTagName("south")[0];southStates=southNode.getElementsByTagName("state");output("
6、南?部?州Y名?",southStates);}functionlistEastStates(){varxmlDOC=XMLHttpRequest.responseXML;vareastStates=xmlDOC.getElementsByTagName("east")[0];eastStates=eastNode.getElementsByTagName("state");output("東?部?州Y名?",eastStates);}functionlistWestStates(){varxmlDOC=XMLHttpRequest.respons
7、eXML;varwestStates=xmlDOC.getElementsByTagName("west")[0];westStates=westNode.getElementsByTagName("state");output("西??部?州Y名?",westStates);}functionlistAllStates(){varxmlDOC=XMLHttpRequest.responseXML;allStates=xmlDOC.getElementsByTagName("state");output("所¨′有?D州Y名?",allStates
8、);}functionoutput(title,states){varout=title;varcurrentSate=n