Usgin Ajax xmlHTTP request to retrieve HTML content into DIV
Posted: Sun Jan 07, 2007 1:28 pm
feyd | Please use
Thanks a lot
Moshe.b
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi There
I cant resolve this issue ..HELP!!
When i run the following code . after click the button i get "undefined" a second click retrieves the actual HTML content
Whats is wrong ?
[syntax="html"]<html>
<head>
<script language="javascript">
var xmlHttp;
var results;
function getXMLHTTP(){
var A = null;
try{
A = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
A = new ActiveXObject("Microsoft.XMLHTTP");
} catch(oc){
A = null;
}
}
if(!A && typeof XMLHttpRequest != "undefined") {
A = new XMLHttpRequest();
}
return A;
}
function getUrl(lookupURL){
if(xmlHttp && xmlHttp.readyState != 0) {
xmlHttp.abort()
}
xmlHttp=getXMLHTTP();
if(xmlHttp){
xmlHttp.open("GET", lookupURL, true);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.responseText) {
results=xmlHttp.responseText;
}
}
xmlHttp.send(null);
}
return results;
} //end function doRemoteQuery
</script>
</head>
<body>
<script language="javascript">
function ShowDiv() {
document.getElementById("urlContent").innerHTML=getUrl('GetMiniProfile.php');
}
</script>
<div id="urlContent"></div>
<br />
<button onclick="ShowDiv()">Click me</button>
</body>
</html>Thanks a lot
Moshe.b
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]