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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.