PDA

View Full Version : How to load a store from a coldfusion component?



marxan
20 Jun 2012, 1:56 AM
Hello,

I'm trying to load data from a coldfusion server but I have the following issue:

"You're trying to decode an invalid JSON String"

When I have a look in firebug, I see that the call is correctly made to my component Loader.cfc but the method called is "getcfcinhtml" instead of "getFamilyCompo".

Here's the call to my component:


Ext.define('TAB.model.FamilyCompoModel', { extend: 'Ext.data.Model',
fields: ['codefc', 'namefc'],
proxy: {
type: 'ajax',
url: 'app/data/Loader.cfc?getFamilyCompo',
/* params:{
method: 'getFamilyCompo',
returnFormat: 'JSON'
},*/
success : function(response){
console.log(response.responseText); //<--- the server response
}
},
reader: {
type: 'json',
root: 'results'
}
}
});

Do I make anything wrong?

Thanks in advance

scottmartin
20 Jun 2012, 3:24 PM
What is your call that is triggering the ajax call?

If you enter the url manually in a browser, do you get the expected result?
Can you review the server side to see if it is getting the correct header info?
Is the header correct?

Scott.

marxan
21 Jun 2012, 7:53 AM
Hi,

I finally found the solution. Here is the code, I had to specify in the url the return format.

I hope this thread will help.


Ext.define('TAB.model.FamilyCompoModel', { extend: 'Ext.data.Model',
fields: [
{name:"CODEFC", type:"string"},
{name:"NAMEFC", type:"string"}
],
proxy: {
type: 'ajax',
url: 'app/data/loader.cfc?method=getFamilyCompo&returnformat=json',
reader: {
type: 'array',
root: 'DATA'
}
}
});

scottmartin
21 Jun 2012, 8:07 AM
Thank you for the follow-up.

Scott.