Jump to content

[SOLVED] Quick on twos


Lefu

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/77738-solved-quick-on-twos/
Share on other sites

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;

}

Link to comment
https://forums.phpfreaks.com/topic/77738-solved-quick-on-twos/#findComment-393519
Share on other sites

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;
               }

Link to comment
https://forums.phpfreaks.com/topic/77738-solved-quick-on-twos/#findComment-393758
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/77738-solved-quick-on-twos/#findComment-393777
Share on other sites

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  ;D rajivgonsalves and the person who wrote the ajax script on phpfreaks ;).

 

Link to comment
https://forums.phpfreaks.com/topic/77738-solved-quick-on-twos/#findComment-393784
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.