View Full Version : Ext.util.JSON.decode() Fail to handle JSON string if obtained trough Ext.ajax.request

13 Aug 2009, 8:19 AM
Hi, I hope you can help me with this:

I've provided a test link here (http://adolisant.laurentchenet.com/cms5/testfolder/index.cfm) for firebug investigation.

I don't know why, but, if I ask ext.decode() to decode directly the JSON string obtained trough Ext.AJAX.request, it fails.

If I copy/paste the string directly in ext.decode() parenthesis, it is working.

It looks like a bug but I'm not sure it is one.

This is the code (Some Coldfusion here too but don't botter with it) you will execute if you click the above link:

<CFHEADER NAME="Pragma" VALUE="no-cache">
<CFHEADER NAME="Expires" VALUE="0"><cfscript>
</cfscript><cfcontent type="text/html; charset=utf-8">
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../js/extjs/resources/css/ext-all.css" />
<SCRIPT type="text/javascript" language="JavaScript" src="../js/extjs/adapter/ext/ext-base.js"></SCRIPT>
<SCRIPT type="text/javascript" language="JavaScript" src="../js/extjs/ext-all.js"></SCRIPT>

<SCRIPT id="customscripts" type="text/javascript" language="JavaScript">
function GetSomeJSONFromColdfusion(menu){
url: '../json.cfc?method=getMenuInfo',
method: 'POST',
params: {
menu_id: menu
success: function(data){
jsondata = Ext.decode(data);
failure: function(){
alert('could not reach server');

<BODY marginheight=0 marginwidth=0 rightmargin=0 bottommargin=0 leftmargin=0 >
This page simply initiate a call to a coldfusion component, getting some JSON back.
But then ext.decode() trhow an error: "missing ] after element list". If, using firebug, you try to ext.decode() manually the string, you'll get successfull. Try to execute <i>Ext.decode('{"TITLE":1}');</i>.

13 Aug 2009, 8:23 AM
Because an Ajax request returns a response object.


13 Aug 2009, 8:49 AM
Because an Ajax request returns a response object.


That was fast. Approximatly 10 time faster than the time I needed to set up the test link :-)

Thank you very much!