View Full Version : Uncaught Ext.Error: You're trying to decode an invalid JSON String:

24 Jul 2012, 8:42 AM
Hi Guys,

I am getting following error which submitting my extjs form.

***Uncaught Ext.Error: You're trying to decode an invalid JSON String***

Please find my code below. Below is my js file.

Ext.onReady(function() {

var simple = Ext.create('Ext.form.Panel', {

frame : true,
title : 'Login Form',
bodyStyle : 'padding:5px 5px 0',
width : 350,
fieldDefaults : {
msgTarget : 'side',
labelWidth : 75
defaultType : 'textfield',
defaults : {
anchor : '100%'

items : [{
fieldLabel : 'User Name',
name : 'userName',
allowBlank : false,
emptyText : 'UserName'
}, {
fieldLabel : 'Password',
name : 'password',
allowBlank : false,
inputType : 'password',
emptyText : 'Password'

buttons : [{
text : 'Save',
handler : function() {
var form = this.up('form').getForm();
url : saveFormUrl
// waitMsg : 'Sending the info...',
// success : function(fp, o) {
// Ext.Msg.alert('Success',
// 'Form submitted.');
// }
}, {
text : 'Cancel'

This is my controller class..

public class UserController {

private static final Logger logger = LoggerFactory

private TService tService = null;

public void setTService(TService tService) {
this.tService = tService;

@RequestMapping(value = "/index.html", method = RequestMethod.GET)
public String home() {
System.out.println("Welcome home!");
return "login";

@RequestMapping(value = "/save-form.html", method = RequestMethod.POST)
public ModelAndView submitData(User user){
System.out.println("User name:"+user.getUserName());
ModelAndView mv = new ModelAndView("htmlLinks");
return mv;

This is my save-form.html file..

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

Welcome User !!

Could anyone tell me what am I doing wrong? and what should I do as a solution? I am using ExtJs 4 and Spring MVC.


24 Jul 2012, 11:53 AM
Please format your code in the future.

What does your return JSON look like? are you encoding/decoding?
If you test you JSON at jsonlint.com, do you get a valid result?


25 Jul 2012, 10:08 AM
Hi ,

I am not encoding/decoding json. I am just trying to submit the data from extjs page.

25 Jul 2012, 10:18 AM
I am just trying to submit the data from extjs page.

right .. but are you receiving this on the response after the submit?


25 Jul 2012, 11:56 AM
I am using Spring MVC in application, so first I am loading the controller and then It goes to jsp page where I have included ext js files and my own js file. Once this login page is loaded, I am submitting the page to spring controller and redirect to another jsp page.


25 Jul 2012, 5:53 PM
The point I am trying to make here is .. when do you receive the error in your code?
What are you using to debug your code? Firebug/DevTools (chrome)

Your error suggests you are trying to decode an return JSON string ..
Do you get a response back from the server?
What does your header look like when you submit?

We have established that you are trying to subtmit data, but what is going on after in the code?


30 Jul 2012, 10:20 AM
Thanks a lot scott for reply. It worked after I made this change for the button.

buttons : [{
text : 'Save',
handler : function() {
// The getForm() method returns the
// Ext.form.Basic instance:
var form = this.up('form').getForm();