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

bing api and datasource

1 Answer 67 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Piyush Bhatt
Top achievements
Rank 2
Piyush Bhatt asked on 13 Jan 2012, 08:50 PM
I am trying to decipher the bing api results with datasource but not having success.

My datasource definiton:
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    type: "GET",
                    contentType: "applicatino/json; charset=utf-8",
                    url: "http://api.bing.net/json.aspx",
                    dataType: "jsonp",
                    data: {
                        AppId: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                        Query: function() { var search = $("#bingSuggest").val(); return search; },
                        Sources: "web",
                        JsonType: "raw",
}//data
}//read
                    }, //transport
                    schema: {
                        data: "SearchResponse"
                    },
                    change: function() {
                        alert(this.view());
                    }
                });

When the JsonType is used as "raw" as soon as the Bing returns results, a javascript error is displayed that the returned response has some syntax error. The reason I believe is - kendo (or jQuery?) tries to send the request with a callback=jquery211212... parameter. But Bing does not recognize this and needs different callback parameter.

2- I tried passing the json callback.

                        JsonType: "callback",
                        JsonCallback: "onBingSearch"

Now, bing returns results and no javascript error logged in console - but the callback is not called. 

Trying to figure out 1) either how to use the 'raw' data or 2) how to get this callback called with the response?

Thanks,
Piyush

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 16 Jan 2012, 10:13 AM
Hello Piyush,

Please check the following jsFidlle to see how to setup the DataSource.
http://jsfiddle.net/rusev/E4NdM/

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Piyush Bhatt
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Share this question
or