Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: missing ; before statement in kendoui

how come when i'm clicking on the update button popup kendo grid , this error ocurrs?

  • The error in Firefox browser is in this form : SyntaxError: missing ; before d.0=value

  • and in Chrome browser : Uncaught SyntaxError: Unexpected number

I've uploaded a video regarding this error for elaboration n stuff

Jsfiddle Code

Video

Code

transport: {
    read: {
        url: 'https://dl.dropboxusercontent.com/sh/u9oxg5f6uweqh40/CbR3pNVg04/documentj',
        dataType: 'json',
        type: 'get',
        cache: false
        },
    update: function(e) { return true; }
}
save: function (e) {
    var that = this;
    $.ajax({
        url: '/echo/json',
        type: e.model.id == null ? 'POST' : 'PUT',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(e.model),
        success: function (data) {
            // Alertify.log.success(data);
            console.log('ok dadasaved');
            that.refresh();
        },
        error: function (data) {
            //  Alertify.log.error(data);
            console.log('no datasaved');
            that.cancelRow();
        }
    });
}
like image 259
object json Avatar asked Oct 22 '22 03:10

object json


2 Answers

You should provide more code to detect what's wrong with your code, but read this may help you:

Such error occurs when the transport definitions are inconsistent. In other words, if you would like to use custom transport method, all transport types should be defined as functions.

Having a standard read transport and custom update is not supported. Please configure all transports as functions and let me know if the error still occurs.

like image 102
Iman Mahmoudinasab Avatar answered Oct 25 '22 17:10

Iman Mahmoudinasab


I had the same error and for me the problem was that the dataType option was not set for all transport methods. I marked that line with a comment below:

var linksDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            dataType: "json",
            url: 'read-url',
            type: "get"
        },
        destroy: {
            dataType: "json", /* <============ THIS LINE WAS MISSING */
            url: 'delete-url',
            type: "delete"
        },
        update: {
            dataType: "json",
            url: 'update-url',
            type: "post"
        },
        create: {
            dataType: "json",
            url: 'create-url',
            type: "post",
            complete: function () {
                $("#searchResult").data("kendoGrid").dataSource.read();
            }
        },
/* ... */
like image 30
Krisztián Balla Avatar answered Oct 25 '22 19:10

Krisztián Balla