Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:21:40+00:00 2026-06-07T12:21:40+00:00

I’m using jqPlot and since I can’t find one decent place to find out

  • 0

I’m using jqPlot and since I can’t find one decent place to find out how to send multiple series to jqplot through JSON, I will try to work around it.

so here’s a little background:

Right now, I can call my servlet and return a JSON array with the data that I’m going to display in the chart.

AJAX CALL

$.ajax({
            type:   'POST',
            cache:  'false',
            data:   params,             
            url:    '/miloWeb/PlotChartServlet',
            async:  false,
            dataType: 'json',
            success: function(series){                  
                coordinates =  [series] ;
            },
            error: function (xhr, ajaxOptions, thrownError){
                alert(ajaxOptions);
            }   
        });

SERVLET

    private void generateCoordinates(HttpServletRequest request, HttpServletResponse response) throws IOException{

    JSONArray coordinates = new JSONArray();
    try {
        coordinates = findChartCoordinatesByPatientPK();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    response.getOutputStream().print(coordinates.toString());

}

What this does is return the string:

[[“07/06/2000″,”22.0”],[“08/06/2000″,”20.0”],[“08/06/2003″,”15.0”],[“08/06/2005″,”35.0”],[“08/06/2007″,”12.0”],[“08/06/2010″,”10.0”],[“08/06/2012″,”10.0”]]

So I store that in the variable ‘coordinates’ and use those to plot the jqPlot graph using:

var plot10 = $.jqplot ('chartdiv', coordinates);

Up To this point everything works great, now comes what I’m trying to achieve:

If I hardcode a String that symbolizes the two arrays inside another array, like so:

[[["07/06/2000","22.0"],["08/06/2000","20.0"],["08/06/2003","15.0"],["08/06/2005","35.0"],["08/06/2007","12.0"],["08/06/2010","10.0"],["08/06/2012","10.0"]], [["07/06/2000","21.0"],["08/06/2000","19.0"],["08/06/2003","14.0"],["08/06/2005","34.0"],["08/06/2007","11.0"],["08/06/2010","9.0"],["08/06/2012","9.0"]]]

I can get the jQplot to plot the two distinct lines in the chart! So I tried doing the same and returning a String exactly like that one through the servlet:

NOT WORKING SERVLET

    private void generateCoordinates(HttpServletRequest request, HttpServletResponse response) throws IOException{
        JSONArray coordinates = new JSONArray();
        JSONArray coordinates2 = new JSONArray();
        try {
            coordinates = VitalsBB.findChartCoordinatesByPatientPK();
            coordinates2 = VitalsBB.findChartCoordinatesByPatientPK2();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        response.getOutputStream().print( coordinates.toString() + ", " + coordinates2.toString());

    }

But that doesn’t work, it gives me a parse Error. So do I need to modify the AJAX call? or is there a way to give back two JSON arrays.toString() to my form and store them in a variable? Or maybe I need two variables?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:21:41+00:00Added an answer on June 7, 2026 at 12:21 pm

    You’re not enclosing the two sub-arrays in outer array brackets when you call response.getOutputStream().print().

    Try this instead:

    response.getOutputStream().print("[" + coordinates.toString() + ", " + coordinates2.toString() + "]");
    

    If your code worked when you hardcoded the array, then this should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am reading a book about Javascript and jQuery and using one of the
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.