473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Extracting arrays from http.reponseText

25
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
1 1913
acoder
16,027 Expert Mod 8TB
Return XML, normal HTML or JSON or something which is easy to parse, e.g. see link.
Apr 9 '07 #2

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

Similar topics

1
by: Cognizance | last post by:
Hi gang, I'm an ASP developer by trade, but I've had to create client side scripts with JavaScript many times in the past. Simple things, like validating form elements and such. Now I've been...
4
by: effendi | last post by:
How can I extract differences between two arrays using Javascript? I hv for example, apple, orange, pear and another array with apple, orange and I would like to get pear. Thanks.
1
by: v0lcan0 | last post by:
Any help on extracting the time part from the datetime field in SQL database. even though i had entered only the time part in the database when i extract the field it gives me only the date...
36
by: Digital Puer | last post by:
Hi, suppose I have an unsigned long long. I would like to extract the front 'n' bits of this value and convert them into an integer. For example, if I extract the first 3 bits, I would get an int...
2
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
2
by: bjm | last post by:
I created a self extracting zip file with about 9000 files in it. I extracted it manually from the command line without a problem. However, when I tried to do the same extraction at the same...
7
by: Umesh | last post by:
How can I extract common elements of two number arrays into another array? // the following doesn't work for(k=0;k<10;k++) for(l=0;l<15;l++) if(p==q) {r=p;++m;}
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
5
by: Mukesh | last post by:
Hi, I am using framework 2.0. I am writing a foreach loop that will extract single dimensional arrays out of double dimensional array. I am trying writing something like this. string ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.