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

Autocomplete with JSONP problems

2 Answers 53 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Stan
Top achievements
Rank 1
Stan asked on 19 Dec 2012, 11:08 PM
I was trying to follow the instructions here: http://docs.kendoui.com/getting-started/web/autocomplete/overview#using-the-kendo-ui-web-datasource-to-bind-to-jsonp ut I am not seeming to get this to work.  When I am looking at the console, the GET request is going out just fine, I just get nothing back.  If I type the url into my browser, it works fine. I am trying to get JSON back (JSONP since it is not the same url) - what am I doing wrong?

Here is my js:
$('#ManufacturerConfirmationId').kendoAutoComplete({
    minLength: 3,
    dataTextField: "ManufacturerConfirmationId",
    filter: "contains",
    dataSource: new kendo.data.DataSource({
        transport: {
            read: {
                url: serviceBase + 'EquipmentWarranties/ManufacturerConfirmationIdsComplete',
                data: {
                    manufacturerId: function () { return $('#ManufacturerId').val(); },
                    manufacturerConfirmationId: function () { return $('#ManufacturerConfirmationId').val(); }
                }
            }
        }
    }),
    change: function () {
        this.dataSource.read();
    }
});

2 Answers, 1 is accepted

Sort by
0
Stan
Top achievements
Rank 1
answered on 20 Dec 2012, 06:07 PM

I am very confused, I changed my code a bit.  This code smoewhat works, sends out the right request and fiddler returns with the json, but nothing pops up in my Firebug or the autocomplete:

manufacturerConfirmationId.kendoAutoComplete({
    minLength: 1,
    dataSource: {
        type: "jsonp",
        transport: {
            read: {
                url: serviceBase + 'EquipmentWarranties/ManufacturerConfirmationIdsComplete',
                data: { manufacturerId: "2",  manufacturerConfirmationId: "64" }
            }
        }
    }
});


FireBug: http://i.imgur.com/eoEzp.png

Any idea what I am doing wrong?

0
Alexander Valchev
Telerik team
answered on 21 Dec 2012, 05:00 PM
Hi Stan,

Regarding the implementation presented at the first post, please do not call dataSource.read() at the change function of the DataSource. The autoComplete widget will maintain its DataSource out of the box. We will also update the code snippet sample in short terms.

Regarding your second post, jsonp should be set as a dataType of the read request. Please try the suggested change and let me know if the problem still persists.

Kind 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!
Tags
AutoComplete
Asked by
Stan
Top achievements
Rank 1
Answers by
Stan
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or