472,779 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 1882
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 ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.