![]() 图1 |
| function Getxml(标准化越来越近了)HttpObject(handler) { var objxml(标准化越来越近了)Http = null; if (!window.xml(标准化越来越近了)HttpRequest) { // Microsoft objxml(标准化越来越近了)Http = GetMSxml(标准化越来越近了)Http(); if (objxml(标准化越来越近了)Http != null) { objxml(标准化越来越近了)Http.onreadystatechange = handler; } } else { // Mozilla | Netscape | Safari objxml(标准化越来越近了)Http = new xml(标准化越来越近了)HttpRequest(); if (objxml(标准化越来越近了)Http != null) { objxml(标准化越来越近了)Http.onload = handler; objxml(标准化越来越近了)Http.onerror = handler; } } return objxml(标准化越来越近了)Http; } function GetMSxml(标准化越来越近了)Http() { var xml(标准化越来越近了)Http = null; var clsids = ["Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.6.0","Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.5.0","Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.4.0","Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.3.0", "Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.2.6","Microsoft.xml(标准化越来越近了)HTTP.1.0", "Microsoft.xml(标准化越来越近了)HTTP.1","Microsoft.xml(标准化越来越近了)HTTP"]; for(var i=0; i<clsids.length && xml(标准化越来越近了)Http == null; i++) { xml(标准化越来越近了)Http = Createxml(标准化越来越近了)Http(clsids[i]); } return xml(标准化越来越近了)Http; } function Createxml(标准化越来越近了)Http(clsid) { var xml(标准化越来越近了)Http = null; try { xml(标准化越来越近了)Http = new ActiveXObject(clsid); lastclsid = clsid; return xml(标准化越来越近了)Http; } catch(e) {} } |
| function GetMSxml(标准化越来越近了)Http() { var xml(标准化越来越近了)Http = null; var clsids = ["Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.6.0","Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.4.0","Msxml(标准化越来越近了)2.xml(标准化越来越近了)HTTP.3.0"]; for(var i=0; i<clsids.length && xml(标准化越来越近了)Http == null; i++) { xml(标准化越来越近了)Http = Createxml(标准化越来越近了)Http(clsids[i]); } return xml(标准化越来越近了)Http; } |
| function Sendxml(标准化越来越近了)HttpRequest(xml(标准化越来越近了)http, url) { xml(标准化越来越近了)http.open('GET', url, true); xml(标准化越来越近了)http.send(null); } |
| var xml(标准化越来越近了)Http; function ExecuteCall(url) { try { xml(标准化越来越近了)Http = Getxml(标准化越来越近了)HttpObject(CallbackMethod); Sendxml(标准化越来越近了)HttpRequest(xml(标准化越来越近了)Http, url); } catch(e){} } //CallbackMethod will fire when the state //has changed, i.e. data is received back function CallbackMethod() { try { //readyState of 4 or 'complete' represents //that data has been returned if (xml(标准化越来越近了)Http.readyState == 4 || xml(标准化越来越近了)Http.readyState == 'complete') { var response = xml(标准化越来越近了)Http.responseText; if (response.length > 0) { //update page document.getElementById("elementId").innerHTML = response; } } } catch(e){} } |
| Page.RegisterStartupScript("ajax(动态网站静态化)Method", String.Format("<script>ExecuteCall('{0}');</script>", url)); |
| private void Page_Load(object sender, EventArgs e) { Response.Clear(); string temp = Request.QueryString["temp"]; if (temp != null) { try { int tempC = int.Parse(temp); string tempF = getTempF(tempC); Response.Write(tempF); } catch {} } Response.End(); } private string getTempF(int tempC) { com.developerdays.ITempConverterservice svc = new ITempConverterservice(); int tempF = svc.CtoF(tempC); return tempF.ToString(); } |
| int tempC = 25; string url = String.Format("http://localhost/" + "getTemp.aspx?temp={0}", tempC); |