We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot populate EJ2(EJS) Schedule from JSON

Referring to this article  In my .cshtml I have this

    <div class="col control-section">
        <div class="content-wrapper">
            @(Html.EJS().Schedule("schedule")
                .Width("100%")
                .Height("650px")
                .EventRendered("onEventRendered")
                //.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
                .EventSettings(e => e.DataSource(d => d.Url("Home/GetAppointmentData").CrudUrl("Home/SaveAppointmentData").Adaptor("UrlAdaptor").CrossDomain(true)))
                .SelectedDate(DateTime.Now).Render()
                )
        </div>
    </div>

Home/GetAppointmentData generates the JSON as in the attached file.

    public class AppointmentData
    {
        public int Id { get; set; }
        public string Subject { get; set; }
        public string Location { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public string CategoryColor { get; set; }
    }

In the browser console, I get this error.

Uncaught SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.parseJson (ej2.min.js:10)
    at e.onSuccess (ej2.min.js:10)
    at e.successHandler (ej2.min.js:10)
    at e.stateChange (ej2.min.js:10)
    at XMLHttpRequest.t.httpRequest.onreadystatechange (ej2.min.js:10)

I have run the content through several JSON parsers online and all of them show no error with the content. What am I missing, please?

There appears to be no format of legal JSON that will get past this error, can anyone help me 

Just as I was starting to make good progress working out how the scheduler actually works because the documentation is poor, incorrect or inconsistent (or all of these).

getappointmentdata_376cff.zip

Attachment: getappointmentdata_4d171cbd.zip

1 Reply

NR Nevitha Ravi Syncfusion Team August 19, 2019 09:47 AM UTC

Hi David, 

Greetings from Syncfusion Support. 

We have checked your code and suspect that your requirement is to perform CRUD actions in scheduler for which we have shared a CRUD sample to load the appointments from the database and insert, update , delete appointments which can be downloaded from the following link. 

If your requirement is to simply load JSON data to the scheduler kindly refer the following UG link. 

Please try the sample and UG link and revert us back with controller side code if you still face any issue to check the issue further. 

Regards, 
Nevitha. 


Loader.
Live Chat Icon For mobile
Up arrow icon