Lefu Posted November 17, 2007 Share Posted November 17, 2007 Greeting in order, I have this functions: 1) function RequestData(target_display,passport,menuid) 2) function stateChanged() 3) function GetXmlHttpObject() from RequestData function I display results using stateChanged function. I need to know how can I pass target_display to stateChaged function? another thing is how do I put the function to be viewed in this forum. where those who wants to see the contents of this functions above are? thanx. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 17, 2007 Share Posted November 17, 2007 can you post your code it would be helpful its hard to say what you wanna achieve without actual code Quote Link to comment Share on other sites More sharing options...
Lefu Posted November 17, 2007 Author Share Posted November 17, 2007 var xmlHttp function parameters(a,b ) { alert(b); document.getElementById(a).innerHTML=b ; } function ContentDisplay(target_display,passport,menuid) { if (menuid.length==0) { document.getElementById(target_display).innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="openedfile.php"; url=url+"?"+passport+"="+menuid; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { //document.innerHTML=; document.getElementById("spnContent").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Quote Link to comment Share on other sites More sharing options...
Lefu Posted November 17, 2007 Author Share Posted November 17, 2007 function RequestData is now ContentDisplay thanx a lot Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 18, 2007 Share Posted November 18, 2007 this should work var xmlHttp function parameters(a,b ) { alert(b); document.getElementById(a).innerHTML=b ; } function ContentDisplay(target_display,passport,menuid) { if (menuid.length==0) { document.getElementById(target_display).innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="openedfile.php"; url=url+"?"+passport+"="+menuid; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange= function(target_display) { if (xmlHttp.readyState==4) { //document.innerHTML=; document.getElementById(target_display).innerHTML=xmlHttp.responseText; } } xmlHttp.open("GET",url,true); xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Quote Link to comment Share on other sites More sharing options...
Lefu Posted November 18, 2007 Author Share Posted November 18, 2007 ok, this is what I have dove to test your solution,rajivgonsalves , I put this line just above to see the results document.getElementById("main").innerHTML=target_display; //document.getElementById(target_display).innerHTML=xmlHttp.responseText; in the body I have div with id="main", I get: undefined Quote Link to comment Share on other sites More sharing options...
Lefu Posted November 18, 2007 Author Share Posted November 18, 2007 I thought I was too smart, at the end the AJAX - a basic start and working example on this forum help me achieve what I needed to achieve, in fact it had the answer for my problem above. thank you once again to rajivgonsalves and the person who wrote the ajax script on phpfreaks . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.