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 9133593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:30:52+00:00 2026-06-17T08:30:52+00:00

I know there are several posts about this but I think I’m missing something.

  • 0

I know there are several posts about this but I think I’m missing something. I’m returning the data below in an ajax call but it doesn’t seem to be in the right format for FLOT. Is there a better format to return the data in or what should be changed for FLOT to recognize it? TIA

<script type="text/javascript">
     $(document).ready(function() {
         // Add the page method call as an onclick handler for the div.
         $("#Result").click(function() {
             $.ajax({
                 type: "POST",
                 url: "WebTest.aspx/GetData",
                 data: "{}",
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",
                 success: function(msg) {
                     // Replace the div's content with the page method's return.

                     var jsObj = []
                     jsObj.push($.parseJSON(msg.d));

                     $.plot($("#Result"), jsObj, {
                         grid: {
                             backgroundColor: "#E5E5E5",

                             mouseActiveRadius: 20
                         }


                     }
                 );
                 }
             });
         });
     });
</script>


[WebMethod]
public static string GetData()
{

    DataLines dataLine1 = new DataLines();
    DataLines dataLine2 = new DataLines();


    int[] lineA_Point1 = new int[] { 4, 6 };
    int[] lineA_Point2 = new int[] { 2, 10};

    List<int[]> dataA = new List<int[]>();
    dataA.Add(lineA_Point1);
    dataA.Add(lineA_Point2);

    dataLine1.data = dataA;
    dataLine1.label = "DataLine1";

    JavaScriptSerializer js = new JavaScriptSerializer();

    string Line1 = js.Serialize(dataLine1);

    return Line1;
}
  • 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-17T08:30:53+00:00Added an answer on June 17, 2026 at 8:30 am

    1.) Convert the JSON string back to a javascript object in your javascript:

    var jsObj = $.parseJSON(d); // using jquery method
    

    2.) In your GetData method, your

    dataLine1.data = "[[1356328800000,5],[1356933600000,3]]";
    

    isn’t going to work. That will make your data element a string in the JSON instead of a javascript array. It would be best to fix this in your WebMethod:

    DataLines dataLine1 = new DataLines();
    dataLine1.data = new List<int[]>();
    dataLine1.data.Add(new int[] {1356328800000,5});
    dataLine1.data.Add(new int[] {1356933600000,3});
    

    That’s totally untested (I’ve never used the JavaScriptSerializer before, but similar code works with the ServiceStack serializer.

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

Sidebar

Related Questions

Possible Duplicate: Objective C for Windows I know there are several posts about this
I know there are several threads and posts regarding this issue in the internet
I know there are several questions about satellite Assembly's out there, but I still
I know there have been several posts about random word generation based on large
I know that there are several posts about how BAD it is to try
I know, there are several posts with nearly the same question, but all the
I know there are a lot of questions about it, but I tried several
I've read several of the posts on stack overflow already about this topic, but
I know there are several threads asking similar questions - but I havent found
I know there are several libraries to connect to XMPP servers, but is there

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.