467,144 Members | 1,418 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,144 developers. It's quick & easy.

Extracting arrays from http.reponseText

I am completely new to this so please bear with me here. My project involves a webpage executing php scripts via an xmlhttprequest which queries a database and returns data to the webpage. This code below is working to a degree in IE7. As I have not yet parsed http.responseText, I am getting all the code in parts.php in the alert. My php script query creates two php arrays, one a single array and a two-dimensional array such as array[][]. My first question is how can I extract these arrays from http.responseText so I can display them. My 2nd is, stepping through the code in tomcat v5.0.28, the script executes the first alert showing http.readyState = 1, but then stops/fails even with the firewall disabled. Looking at the code below, can anyone suggest a possible reason why? Any help appreciated.

RPJD :)

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr" lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <script language="JavaScript">
  6. function Parts()
  7. var url="http://localhost:8080/Databases/parts.php"; 
  8. if(window.XMLHttpRequest)
  9. http = new XMLHttpRequest(); 
  10. else if (window.ActiveXObject)
  11. http  = new ActiveXObject(Microsoft.XMLHTTP); 
  12. http.onreadystatechange = function()
  13.     { 
  14.     alert(http.readyState);
  15.     if(http.readyState == 4)
  16.         {
  17.         alert(http.status);
  18.         if(http.status == 200)
  19.             {
  20.             result = http.responseText;
  21.             alert(result);
  22.             }    
  23.         else    
  24.             {
  25.             // + " " + http.statusText;
  26.             }    
  27.         } 
  28.     }
  29. http.open("GET", url, true); 
  30. http.setRequestHeader("text/xml"); 
  31. http.send(null); 
  32. </script>
  33. </head>
  34. <body>
  35. <FORM name="description" method="POST" action="">
  36. <p>
  37. <INPUT type="BUTTON" value="Parts"  ONCLICK="Parts();">
  38. </p>
  39. <p>
  40.  
  41. </body>
  42. </html>
  43.  
Apr 6 '07 #1
  • viewed: 1604
Share:
1 Reply
acoder
Expert Mod 8TB
Return XML, normal HTML or JSON or something which is easy to parse, e.g. see link.
Apr 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by effendi@epitome.com.sg | last post: by
36 posts views Thread by Digital Puer | last post: by
2 posts views Thread by bjm | last post: by
7 posts views Thread by Umesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.