function GetMSXmlHttp() { var xmlHttp = null; var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0"]; for(var i=0; i<clsids.length && xmlHttp == null; i++) { xmlHttp = CreateXmlHttp(clsids[i]); } return xmlHttp; } |
function SendXmlHttpRequest(xmlhttp, url) { xmlhttp.open(''GET'', url, true); xmlhttp.send(null); } |
var xmlHttp; function ExecuteCall(url) { try { xmlHttp = GetXmlHttpObject(CallbackMethod); SendXmlHttpRequest(xmlHttp, 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 (xmlHttp.readyState == 4 || xmlHttp.readyState == ''complete'') { var response = xmlHttp.responseText; if (response.length > 0) { //update page document.getElementById("elementId").innerHTML = response; } } } catch(e){} } |
Page.RegisterStartupScript("ajaxMethod", 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(); } |