How to create a JQuery or Javascript Array from HTML Formatted HTTP Response?
I'm using a service called TrueFX that provides currency information based on HTTP request/response. I need to send the initial request to the base URL with username, and other parameters. The service responds with a session ID. A subsequent HTTP request is sent with the session ID and the instructions for output type (CSV or HTML). The second response provides an HTML table with the requested data.
The final destination for this data will be a chart via the JQPlot plugin for JQuery. JQPlot will accept an array instead of individual values to be plotted.
Questions:
- Is it best to create the array of data using JQuery, plain ole Javascript or PHP?
- Depending on response to above, how do I define the request to TrueFX, the TrueFX response containing currency data in HTML format? Is this just done through the $.ajax JQuery method?
- How do I create and save the array for reference and use in m开发者_运维知识库y call to JQPlot?
Thanks so much for your advice, help and guidance.
First off I would recommend you work with the CSV format as it will be much easier to parse into an array of arrays for use in your chart (also data size will be much smaller). There are multiple CSV plugins for jquery that make this parsing pretty easy. Here is one I found real quick: CSV Plugin
You can use jquery's $.ajax to get the data from the remote service (using JSONP) and the CSV plugin to parse the returned data. Then you feed the resulting array of arrays into your chart.
精彩评论