1

I am getting an InvalidJSONprimitive error that's driving me crazy. Here's the code - any ideas what I am missing?

I've also tried passing the ID parameter as a string (data: '{"ID":"' + 999 + '"}'), and changing dataType to text - same error.

Thanks in advance!

var params = {ID: 999};

    $(document).ready(function () {
    $('#ddl').kendoComboBox({
        filter: "contains",
        dataTextField : "DBA",
        dataValueField: "ID",
        dataSource: {
            transport: {
                read: {
                    type: "POST",
                    cache: false,
                    data: JSON.stringify(params),
                    url: "../webservices/data.asmx/GetDBA",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                }
            }
        }
    });

});
christok
  • 1,087
  • 2
  • 12
  • 29

2 Answers2

2

Your JSON is probably being URL encoded; see my answer here for one approach. Alternatively, using this should work too, I think:

var params = {
    ID: 999
};

(make sure the parameter name is the same as in your server-side service)...

transport: {
    read: {
        type: "POST",
        cache: false,
        data: params,
        url: "../webservices/data.asmx/GetDBA",
        contentType: "application/json; charset=utf-8",
        dataType: "json"
    },
    parameterMap: function (data, type) {
        return kendo.stringify(data);
    }
}

If those solutions don't work, you should inspect the string that is arriving at the server and append that to your question.

Community
  • 1
  • 1
Lars Höppner
  • 18,252
  • 2
  • 45
  • 73
1

quotes around ID

var params = {'ID': 999};

jollarvia
  • 349
  • 4
  • 9