PDA

View Full Version : Problem with .net webservice, JsonStore and ComboBox



a06mikkl
23 Apr 2010, 5:46 AM
Hello.
I'm new to Extjs and have run into a problem.
I'm trying to make an autocomplete combobox on my website using .net on the serverside.

When i start typing "test" in the combobox, i get this error in firebug:

{"Message":"Invalid JSON primitive: test.","StackTrace": This is my client side code:

var store = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({

url: 'Services/SearchAutoCompleteService.asmx/GetResult',
method: 'GET',
headers: {
'Content-type': 'application/json'
}
}),
root: 'd',
id: 'id',
fields:[{name:'type', mapping: 'type'}, {name:'id', mapping: 'id'}, {name:'latitude', mapping: 'latitude'}, {name:'longitude', mapping: 'longitude'}]
});

var combo = new Ext.form.ComboBox({
store: store,
displayField:'type',
typeAhead: false,
mode: 'remote',
queryParam: 'prefixText',
hideTrigger: true,
selectOnFocus:true,
width: 250,
renderTo: 'panel',
triggerAction: 'all'
});My webservice method on the serverside is decorated with the following tags:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
public List<SearchItem> GetResult(string prefixText)
{...
Please help me out, I have searched the web for a solution for a while now and I'm getting kinda frustrated :(
How can i make the data sent to the server into a valid json primitive? Why do i need to, can't I just send ordinary strings??

/Mikael