Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Unexpected token ILLEGAL

In my project I want to display the popup while clear the kendo-grid by clicking "button" but I am getting SyntaxError: Unexpected token ILLEGAL error occurred in browser debug

Here is my code:

function Filter() {
     $("#loading-msg").data("kendoWindow").center().open();
            $("form.k-filter-menu button[type='reset']").trigger("click");
    $("#loading-msg").data("kendoWindow").center().close();
}

Where I am wrong? Why I am getting this error?

My fiddle.

like image 390
user123 Avatar asked Mar 22 '13 06:03

user123


People also ask

What is unexpected token if?

Like other programming languages, JavaScript has define some proper programming rules. Not follow them throws an error.An unexpected token occurs if JavaScript code has a missing or extra character { like, ) + – var if-else var etc}. Unexpected token is similar to syntax error but more specific.

What is an unexpected syntax error?

Syntax Error – This error is caused by an error in the PHP structure when a character is missing or added that shouldn't be there. Unexpected – This means the code is missing a character and PHP reaches the end of the file without finding what it's looking for.

How do I fix SyntaxError unexpected identifier?

To solve the "Uncaught SyntaxError: Unexpected identifier" error, make sure you don't have any misspelled keywords, e.g. Let or Function instead of let and function , and correct any typos related to a missing or an extra comma, colon, parenthesis, quote or bracket.


1 Answers

Instead of executing the close just after issuing the filter. My recommendation is closing the window on DataSource requestEnd event.

I.e.: Clear filter:

function clearFiter() {
    $("#loading-msg").data("kendoWindow").center().open();
    $("#grid").data("kendoGrid").dataSource.filter([]);
}

and DataSource:

dataSource: {

    type: "odata",
    transport: {
        read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
    },
    schema: {
        model: {
            fields: {
                OrderID: { type: "number" },
                Freight: { type: "number" },
                ShipName: { type: "string" },
                OrderDate: { type: "date" },
                ShipCity: { type: "string" }
            }
        }
    },
    pageSize: 10,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true,
    requestEnd : function () {
        $("#loading-msg").data("kendoWindow").close();
    }
},

Your code modified here : http://jsfiddle.net/OnaBai/MG89G/595/

like image 166
OnaBai Avatar answered Oct 25 '22 03:10

OnaBai