This is a migrated thread and some comments may be shown as answers.

parsing error Unexpected token ':'

3 Answers 1584 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Hammad
Top achievements
Rank 1
Hammad asked on 02 Apr 2012, 12:51 PM
Hi,

I am trying to show remote data in grid, my dataSource config is like this:

var items= new kendo.data.DataSource({                            
    transport: {
        read: {
            url: "http://localhost:59515/HTML/Service.svc/Temp",
            dataType: "jsonp",
            data: {                                        
            }
        }
    },
    error: function(e) {
        console.log(e);
    },
    schema:
    {
        data:"d",
        model:
        {
            fields:
            {
                Text: {
                    editable:true, validation: {  required:true  }
                },
                Qty: {
                    editable: true,  type:"number",  validation: {   required:true,   min:1   }
                },
                Val: {
                    editable:false
                }
            }
        }
    }
    }
);

Response JSON:
{
"d":
[
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"},
    {"__type":"MyClass:#","Qty":"4","Text":"195\/65R15 Sportiva","Val":"45.54"}
]
}

No data is displayed in the grid, though the error event handler of dataSource is called and the console.log shows following error:
  1. line: 2
  2. message: "Unexpected token ':'"
  3. sourceId: 2055063872
  4. sourceURL: "http://localhost:59515/HTML/kendo/js/jquery.min.js"
  5. status: "parsererror"

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 02 Apr 2012, 01:57 PM
Hello Hammad,

Please note that your server is returning Json, while the dataType in transport configuration is set to "jsonp". Most probably that is causing the trouble, please try to read the dataSource with the corresponding dataType and let me know if that helps.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Hammad
Top achievements
Rank 1
answered on 02 Apr 2012, 02:00 PM
@Alexander

thanks, changing it to json works :)
0
Inbxx
Top achievements
Rank 1
answered on 09 Aug 2013, 10:53 AM
@Alexander
Thank you :)
Ive been facing this problem for 5 days. i tried everything possible.
Tags
Data Source
Asked by
Hammad
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Hammad
Top achievements
Rank 1
Inbxx
Top achievements
Rank 1
Share this question
or