title: Uncaught TypeError: Cannot read property '0' of undefined - in jqGrid Spring MVC
body: <p>I got the message : Uncaught TypeError: Cannot read property '0' of undefined in jqGrid.min.js . When I submit to update data from grid.</p>
  
  <p>my script: </p>
  
  <pre><code>$('#list-student').jqGrid({
      url: 'GetAllStudent',
      datatype: 'json',
      colNames:['ID','Student', 'Birth day', 'Is Male ?','Province'],
      colModel:[
          {name:'id',index:'id', editable:false,width:100, align:'center'},
          {name:'name',index:'name',editable:true, width:240},
          {
              name:'birth',
              index:'birth',
              editable:true,
              width:200,
              align:'center',
              editoptions:{
                  size:12,
                  dataInit:function(el){
                      $(el).datepicker({dateFormat:'yy-mm-dd',
                          beforeShow: function(){
                              $('.ui-datepicker').css({'font-size': 11, 'line-height': 1.2})
                              }   
                      });
                  }
              },
              editrules:{required:true}
          },
          {name:'male',index:'male', editable:true, formatter:'checkbox',width:100, align:'center',edittype:'checkbox',editoptions:{value:'true:false'}},
          {name:'homeTown.nameProvince',editable:true, index:'province', align:'center',edittype:'select',editoptions:{dataUrl:'GetAllProvinceHTML'}}     
      ],
      jsonReader : {repeatitems:false},
      rowNum: 10,
      rowList:[10,20,30],
      pager: '#pager',
      sortname: 'id',
      viewrecords: true,
      height: 'auto',
      width: 'auto',
      sortorder: 'asc',
      loadonce: true,
      caption:'List Students',
      editurl: 'EditStudent'
  });
  
  $('#list-student').jqGrid(
      'navGrid',
      '#pager',
      {view:true},
      {
          reloadAfterSubmit:false, 
          closeOnEscape:true,
          jqModal:true,
          afterSubmit:function(response, post_data){
              console.log(response.responseText);
          },
          closeAfterEdit: true
      }, // edit options
      {reloadAfterSubmit:false,jqModal:true, closeOnEscape:true,bottominfo:'Fields marked with (*) are required', closeAfterAdd: true}, // add options
      {reloadAfterSubmit:false,jqModal:true, closeOnEscape:true}, // del options
      {closeOnEscape:true}, // search options
      {jqModal:true,closeOnEscape:true} // view options       
  );    
  </code></pre>
  
  <p>in Spring Controller </p>
  
  <pre><code>package controller;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import model.Province;
  import model.ProvinceService;
  import model.Student;
  import model.StudentService;
  
  import org.springframework.http.MediaType;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  @Controller
  @RequestMapping(value="PostMes", method = RequestMethod.POST)
  public class StudentController {
      @RequestMapping(value="Get",method = RequestMethod.GET)
      public String abc(){
          return "Manage";
      }
      @RequestMapping(value="GetAllStudent",method = RequestMethod.GET)
      public @ResponseBody List&lt;Student&gt; getAllStudent(){
          StudentService sts=new StudentService();
          List&lt;Student&gt; list= sts.getAllStudents();
          return list;
      }
      @RequestMapping(value="GetAllProvince",method = RequestMethod.GET)
      public @ResponseBody List&lt;Province&gt; getAllProvince(){
          ProvinceService sts=new ProvinceService();
          List&lt;Province&gt; list= sts.getAllProvinces();
          return list;
      }
      @RequestMapping(value = "GetAllProvinceHTML", method = RequestMethod.GET, produces = "text/html;charset=UTF-8")
      public  @ResponseBody String getAllProcinveHTML(HttpServletResponse response){
          ProvinceService sts=new ProvinceService();
          List&lt;Province&gt; list= sts.getAllProvinces();
          String returnString="";
          for(Province pro:list){
              returnString+="&lt;option id='"+pro.getId()+"'&gt;"+pro.getNameProvince()+"&lt;/option&gt;";    
          }
          returnString="&lt;select class='provinceGroup'&gt;" + returnString + "&lt;/select&gt;"; 
          response.setContentType("text/html");
          response.setCharacterEncoding("UTF-8");
          return returnString;
      }
      @RequestMapping(value = "EditStudent",method = RequestMethod.POST)
      public @ResponseBody List&lt;Student&gt; editStudent(HttpServletRequest request, HttpServletResponse res){
          System.out.println(request.getParameter("id"));
          System.out.println(request.getParameter("oper"));//what operation we re doing example: "add" , "edit"
          System.out.println("Controller recieved");
          List&lt;String&gt; returnList=new ArrayList&lt;String&gt;();
          List&lt;Student&gt; list=new ArrayList&lt;Student&gt;();
          Student st=new Student();
          st.setName("Shayne");
          list.add(st);
          list.add(st);list.add(st);list.add(st);list.add(st);
          return list;
      }
  }
  </code></pre>
  
  <p>When I edit a row, and click submit => in controller received request , but after sent response to client I got message "Uncaught TypeError: Cannot read property '0' of undefined in jqGrid.min.js" </p>
  
  <p>my include : </p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"&gt;&lt;/script&gt;
  &lt;script src="${pageContext.request.contextPath}/resources/js/jqGrid/grid.locale-en.js"&gt;&lt;/script&gt;
  &lt;script src="${pageContext.request.contextPath}/resources/js/jqGrid/jqGrid.min.js"&gt;&lt;/script&gt;    
  </code></pre>