Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I grab html Pipe-delimited Ajax response?

Posted on 2007-11-20
1
Medium Priority
?
874 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…
Suggested Courses

927 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