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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cannot populate EJ2(EJS) Schedule from JSON

Thread ID:

Created:

Updated:

Platform:

Replies:

146743 Aug 16,2019 07:57 PM UTC Aug 19,2019 09:47 AM UTC ASP.NET MVC 1
loading
Tags: Schedule
David Jackson
Asked On August 16, 2019 07:57 PM UTC

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

Nevitha Ravi [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon