ajax - JSON output from web method -


i have web method returning json fullcalendar event data "()" added causing parser error.

i able clip off unwanted "()" , attach events jquery don't want keep way.

the source of data web method using razor. using json helper encode data results in formed json string, i.e. no "()". of course if use encode use response.write send data ajax function. same ill formed json data recieved if use json.write(data, response.output).

catching returned data in success function shows data attached "()".

here portion of web method returns data:

    // convert header names , data strings      var rows = e in ce                select new                {                    id = e.evid,                    title = e.title,                    start = e.startt,                    allday = false,                    end = e.endt,                    backgroundcolor = e.eventcolor                };      string mjson = json.encode(rows);     //json.write(rows, response.output);     response.write(mjson.trim()); 

here result of encode:

    "[{\"id\":9,\"title\":\"new event\",\"start\":\"2012-05-29 19:00:00\",\"allday\":false,\"end\":\"2012-05-29 20:00:00\",\"backgroundcolor\":\"orange    \"},{\"id\":9,\"title\":\"new event\",\"start\":\"2012-06-05 19:00:00\",\"allday\":false,\"end\":\"2012-06-05 20:00:00\",\"backgroundcolor\":\"orange    \"},{\"id\":9,\"title\":\"new event\",\"start\":\"2012-06-12 19:00:00\",\"allday\":false,\"end\":\"2012-06-12 20:00:00\",\"backgroundcolor\":\"orange    \"},{\"id\":10,\"title\":\"another\",\"start\":\"2012-06-22 19:00:00\",\"allday\":false,\"end\":\"2012-06-22 19:45:00\",\"backgroundcolor\":\"orange    \"},{\"id\":10,\"title\":\"another\",\"start\":\"2012-06-29 19:00:00\",\"allday\":false,\"end\":\"2012-06-29 19:45:00\",\"backgroundcolor\":\"orange    \"}]"  string 

here ajax success function shows recieved data:

    "[{"id":9,"title":"new event","start":"2012-05-29 19:00:00","allday":false,"end":"2012-05-29 20:00:00","backgroundcolor":"orange    "},{"id":9,"title":"new event","start":"2012-06-05 19:00:00","allday":false,"end":"2012-06-05 20:00:00","backgroundcolor":"orange    "},{"id":9,"title":"new event","start":"2012-06-12 19:00:00","allday":false,"end":"2012-06-12 20:00:00","backgroundcolor":"orange    "},{"id":10,"title":"another","start":"2012-06-22 19:00:00","allday":false,"end":"2012-06-22 19:45:00","backgroundcolor":"orange    "},{"id":10,"title":"another","start":"2012-06-29 19:00:00","allday":false,"end":"2012-06-29 19:45:00","backgroundcolor":"orange    "}]();???" 


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -