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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:15:29+00:00 2026-06-04T18:15:29+00:00

I’m trying to create a webservice in asp that will be user in jQuery.Gantt

  • 0

I’m trying to create a webservice in asp that will be user in jQuery.Gantt http://mbielanczuk.com/jquery-gantt/

The format that is supported by this plugin looks like this:

[{  "name"  : "Task#1"
, "desc"  : " Task Desc"
, "values": [
  {  "from"       : "/Date(1296547200000)/"
   , "to"         : "/Date(1296554400000)/"
   , "desc"       : "<b>Task #1<br>"
   , "customClass": "ganttRed" (optional)
   , "label"      : "Task #1" (optional)
  },
  {  "from"       : "/Date(1296637200000)/"
   , "to"         : "/Date(1296649800000)/"
   , "desc": "<b>Task #</b>"
   , "customClass": "ganttOrange" (optional)
   , "label": "Task #1" (optional)
  }
]
},
...
]

I have created a webservice using JSON.NET that looks like so:

[JsonObject(MemberSerialization.OptIn)]
public class Meeting
{
    [JsonProperty]
    public string name { get; set; }
    [JsonProperty]
    public string desc { get; set; }
    [JsonProperty]
    public List<Value> values { get; set; }
}

[JsonObject(MemberSerialization.OptIn)]
public class Value
{
    [JsonProperty]
    public string id { get; set; }
    [JsonProperty]
    public DateTime from { get; set; }
    [JsonProperty]
    public DateTime to { get; set; }
    [JsonProperty]
    public string desc { get; set; }
    [JsonProperty]
    public string customClass { get; set; }
}

[WebMethod(Description = "simple test")]
    public string JSON_Test()
    {
        Meeting m1 = new Meeting { name = "one",
        desc = "ole",
        values = new List<Value> { 
            new Value { customClass = "1", desc = "no desc", from = new DateTime(2011, 12, 29, 0, 0, 0, DateTimeKind.Utc), to = new DateTime(2011, 12, 29, 0, 0, 0, DateTimeKind.Utc), id = "3" },
            new Value { customClass = "2", desc = "no desc1", from = new DateTime(2011, 12, 19, 0, 0, 0, DateTimeKind.Utc), to = new DateTime(2011, 12, 20, 0, 0, 0, DateTimeKind.Utc), id = "4" }
        } 
    };
        Meeting m2 = new Meeting
        {
            name = "second",
            desc = "desc",
            values = new List<Value> { 
            new Value { customClass = "1", desc = "no desc", from = new DateTime(2011, 11, 29, 0, 0, 0, DateTimeKind.Utc), to = new DateTime(2011, 12, 29, 0, 0, 0, DateTimeKind.Utc), id = "3" },
            new Value { customClass = "2", desc = "no desc1", from = new DateTime(2011, 11, 19, 0, 0, 0, DateTimeKind.Utc), to = new DateTime(2011, 12, 20, 0, 0, 0, DateTimeKind.Utc), id = "4" }
        }
        };
        List<Meeting> meetings = new List<Meeting>();
        meetings.Add(m1);
        meetings.Add(m2);

        JsonSerializerSettings microsoftDateFormatSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat };

        return JsonConvert.SerializeObject(meetings, microsoftDateFormatSettings);
    }

What I have now looks like this (firebug output):

{"d":"[{\"name\":\"one\",\"desc\":\"ole\",\"values\":[{\"id\":\"3\",\"from\":\"\\/Date(1325116800000)\\/\",\"to\":\"\\/Date(1325116800000)\\/\",\"desc\":\"no desc\",\"customClass\":\"1\"},{\"id\":\"4\",\"from\":\"\\/Date(1324252800000)\\/\",\"to\":\"\\/Date(1324339200000)\\/\",\"desc\":\"no desc1\",\"customClass\":\"2\"}]},{\"name\":\"second\",\"desc\":\"desc\",\"values\":[{\"id\":\"3\",\"from\":\"\\/Date(1322524800000)\\/\",\"to\":\"\\/Date(1325116800000)\\/\",\"desc\":\"no desc\",\"customClass\":\"1\"},{\"id\":\"4\",\"from\":\"\\/Date(1321660800000)\\/\",\"to\":\"\\/Date(1324339200000)\\/\",\"desc\":\"no desc1\",\"customClass\":\"2\"}]}]"}

This if working example that was modified by hand:

[{ "desc": "ole",
"name": "one",
"values": [{ "customClass": "1",
    "desc": "no desc",
    "from": "/Date(1325116800000)/",
    "id": "3",
    "to": "/Date(1325116800000)/"
},
    { "customClass": "2",
        "desc": "no desc1",
        "from": "/Date(1324252800000)/",
        "id": "4",
        "to": "/Date(1324339200000)/"
    }
  ]
}]

For some reason my service is adding extra {“d”:” and some slashes.
I was trying to figure this out trying to build custom serializer, but I’m stuck.

How to fix problem with that extra d on the beginning, “ and slashes?
Maybe I’m trying to reinvent the wheel and this is just a simple setting.

EDIT

This is code from jQuery.Gantt plugin that reads json data:

    var core = {
        /**
        * Create header
        */
        create: function(element) {
            /**
            * Retrieve data
            */
            if (typeof (settings.source) == 'object') {

                element.data = settings.source;
                core.init(element);

            } else {

                $.ajaxSetup({ scriptCharset: "utf-8", contentType: "application/json; charset=utf-8" });
                $.getJSON(settings.source, function(jsData) {
                    element.data = jsData;
                    core.init(element);
                });
            }

        },

How to change it to work correctly with d?

EDIT2

Got it working like this:

create: function(element) {
/**
* Retrieve data
*/
if (typeof (settings.source) == ‘object’) {

            if (settings.source.hasOwnProperty("d"))
                element.data = settings.source.d;
            else
                element.data = settings.source;
            core.init(element);
            } else {

                $.ajaxSetup({
                    scriptCharset: "utf-8",
                    contentType: "application/json; charset=utf-8"
                });
                $.getJSON(settings.source, function(jsData) {

                    if (jsData.hasOwnProperty("d"))
                        element.data = jsData.d;
                    else
                        element.data = jsData;
                    core.init(element);
                });
            }

        }

But somehow my webservice is returning xml.
I’ve added:

 [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

But when looking in firebug I get this:

<?xml version="1.0" encoding="utf-8"?>
 <ArrayOfMeeting xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.site.pl/">
<Meeting>
<name>one</name>
<desc>ole</desc>
<values>
  <Value>
    <id>3</id>
    <from>2011-12-29T00:00:00Z</from>
    <to>2011-12-29T00:00:00Z</to>
    <desc>no desc</desc>
    <customClass>1</customClass>
  </Value>
  <Value>
    <id>4</id>
    <from>2011-12-19T00:00:00Z</from>
    <to>2011-12-20T00:00:00Z</to>
    <desc>no desc1</desc>
    <customClass>2</customClass>
  </Value>
</values>
</Meeting>
<Meeting>
<name>second</name>
<desc>desc</desc>
<values>
  <Value>
    <id>3</id>
    <from>2011-11-29T00:00:00Z</from>
    <to>2011-12-29T00:00:00Z</to>
    <desc>no desc</desc>
    <customClass>1</customClass>
  </Value>
  <Value>
    <id>4</id>
    <from>2011-11-19T00:00:00Z</from>
    <to>2011-11-20T00:00:00Z</to>
    <desc>no desc1</desc>
    <customClass>2</customClass>
  </Value>
</values>
</Meeting>
</ArrayOfMeeting>
  • 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-04T18:15:30+00:00Added an answer on June 4, 2026 at 6:15 pm

    I think there are a couple of things going wrong here.

    1. You don’t need to jsonify the response of the webmethod, asp.net does this for you.

    2. ASP.net webservices wrap the response with this d parent, so you might need to do something like this to make the string into an object.

      var data = eval(response.d)

      $(“.gantt”).gantt({source: data})

    OK eval might not work here so try – http://api.jquery.com/jQuery.parseJSON/

    Update Call $.getJSON yourself **

    OK I see what is going on now. If you use ASP.NET webservices / page methods you will always have the d wrapper I believe.

    You need to call $.getJSON yourself and get the response and then pass that into the create method.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.