Solved

How do I grab html Pipe-delimited Ajax response?

Posted on 2007-11-20
1
865 Views
Last Modified: 2012-06-21
I have an ajax process that calls another page and that page returns an html page with just rows of pipe-delimited records on the page. How do I take that response from xmlHttp.response.Text and put into a multi-dimensional array, so each row is an element of the array. And the pipe separates each field of the row?
0
Comment
Question by:bemara57
1 Comment
 
LVL 7

Accepted Solution

by:
bdichiara earned 500 total points
ID: 20323596
////////    html    //////////

dog|cat|bird
red|blue|green
hot|cold|warm

////////    javascript    //////////

function convert(theHtml){
      var firstArray = theHtml.split("\n"); // this might need to change if using <br> instead of new lines.
      var finalArray = new Array();
      for(var i=0; i < firstArray.length; i++){
            finalArray[finalArray.length] = firstArray[i].split("|");
      }
      
      //you're all set. below just shows you it's in a 2-dimensional array
      for(var f=0; f < finalArray.length; f++){
            for(var c=0; c < finalArray[f].length; c++){
                  alert(finalArray[f][c]);
            }
      }
      
      return finalArray;
}
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now