title: SyntaxError: JSON.parse: unexpected character while call ajax with codeigniter
body: <p>I am using codeigniter. When I call an ajax request to the page by giving the full path to file, it works fine:</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;title id='Description'&gt;In this example is demonstrated how to implement server filtering, sorting and paging with jqxGrid.&lt;/title&gt;
      &lt;link rel="stylesheet" href="http://localhost/jqwidgets-ver3.2.1/jqwidgets/styles/jqx.base.css" type="text/css" /&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/scripts/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxcore.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxbuttons.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxscrollbar.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxmenu.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxgrid.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxgrid.selection.js"&gt;&lt;/script&gt;   
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxgrid.filter.js"&gt;&lt;/script&gt;  
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxgrid.sort.js"&gt;&lt;/script&gt;        
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxdata.js"&gt;&lt;/script&gt; 
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxlistbox.js"&gt;&lt;/script&gt;  
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxgrid.pager.js"&gt;&lt;/script&gt;       
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/jqwidgets/jqxdropdownlist.js"&gt;&lt;/script&gt; 
      &lt;script type="text/javascript" src="http://localhost/jqwidgets-ver3.2.1/scripts/demos.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          // prepare the data
          var source =
          {
              datatype: "json",
              datafields: [
              { name: 'ShipName', type: 'string'},
              { name: 'ShipAddress', type: 'string' },
              { name: 'ShipCity', type: 'string' },
              { name: 'ShipCountry', type: 'string' }
          ],
          cache: false,
          url: 'http://localhost/CodeIgniter_2.1.4/index.php/blog/controllerfunction',
          filter: function()
          {
              // update the grid and send a request to the server.
              $("#jqxgrid").jqxGrid('updatebounddata', 'filter');
          },
          sort: function()
          {
              // update the grid and send a request to the server.
              $("#jqxgrid").jqxGrid('updatebounddata', 'sort');
          },
          root: 'Rows',
          beforeprocessing: function(data)
          {       
              if (data != null)
              {
                  source.totalrecords = data[0].TotalRows;                    
              }
          }
          };      
          var dataadapter = new $.jqx.dataAdapter(source, {
              loadError: function(xhr, status, error)
              {
                  alert(error);
              }
          }
          );
  
          // initialize jqxGrid
          $("#jqxgrid").jqxGrid(
          {       
              source: dataadapter,
              width: "100%",
              filterable: true,
              sortable: true,
              autoheight: true,
              pageable: true,
              virtualmode: true,
              rendergridrows: function(obj)
              {
                  return obj.data;    
              },
              columns: [
                  { text: 'Ship Name', datafield: 'ShipName'},
                  { text: 'Address', datafield: 'ShipAddress'},
                  { text: 'City', datafield: 'ShipCity'},
                  { text: 'Country', datafield: 'ShipCountry'}
              ]
          });
      });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body class='default'&gt;
      &lt;h1&gt;Shipment Records&lt;/h1&gt;
      &lt;div style="width: 1000px" id="jqxgrid"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>works fine with </p>
  
  <pre><code>url: 'http://localhost/CodeIgniter_2.1.4/application/view/serverfiltering_paging_and_sorting_data.php',
  </code></pre>
  
  <p>but </p>
  
  <pre><code>url: 'http://server/CodeIgniter_2.1.4/index.php/controllername/controlerfunction',
  </code></pre>
  
  <p>shows an error : SyntaxError: JSON.parse: unexpected character</p>
  
  <p>I did not make any other change in the code. </p>