Solved

How do I grab html Pipe-delimited Ajax response?

Posted on 2007-11-20
1
871 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

705 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