snowboardr
Programmer
I got a code snippet here from BabyJeff, and it works great for ajax in all the browsers i needed it to work in... but I am having problems returning innerHtml with this exact code... now I have code that does return the html correctly, but it doesnt work in IE.. could someone help me mesh these two codes together?
This is the code i use now, but can't get it working with the innerHtml (this code works for saving however)
This code works in returning innerHTML, I have tried everything in regards to try and "join" the two together etc.. Because i would like as many browsers as i can to work.
Regards,
Jason
This is the code i use now, but can't get it working with the innerHtml (this code works for saving however)
Code:
var xmlHttp
function SaveCollapse(intCall,SaveThis,queryid)
{
var url="ajax_save.asp?call=" + intCall + "&save=" + SaveThis + "&id=" + queryid
xmlHttp=createRequestObject()
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function createRequestObject() {
var ro;
/*@cc_on
@if (@_jscript_version >= 5)
try {
ro = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ro = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
ro = false;
}
}
@else
ro = false;
@end @*/
if (!ro && typeof XMLHttpRequest != 'undefined') {
try {
ro = new XMLHttpRequest();
} catch (e) {
ro = false;
}
}
return ro;
}
This code works in returning innerHTML, I have tried everything in regards to try and "join" the two together etc.. Because i would like as many browsers as i can to work.
Regards,
Jason
Code:
var xmlHttp
function showCustomer(str)
{
var url="ajax_save.asp?call=4&sid=" + Math.random() + "&save=" + str
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("searchresults").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject(handler)
{
var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera")
return;
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
}
try
{
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler
return objXmlHttp
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled")
return
}
}
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler
return objXmlHttp
}
}