views:

2058

answers:

2

I am writing some code to educate myself in the ways of ExtJS. I am also new to JSON so hopefully this question will be easy for you to answer. I am trying to retrieve some data from a basic web service that I have written which should be returning its results as JSON (seeing as I am new to JSON - it could be that that is broken).

The error I am getting is

SyntaxError: missing ) in parenthetical

The JSON that I am returning from my web service is

{"rows":[ { "id": "100000", "genre_name":"Action", "sort_order": "100000" } , { "id": "100002", "genre_name":"Comedy", "sort_order": "100002" } , { "id": "100001", "genre_name":"Drama", "sort_order": "100001" } ]}

My ExtJS code is as below. The loadexception callback is where I have retrieved the JSON and error above from

  var genres = new Ext.data.Store({
   proxy: new Ext.data.HttpProxy({
    method: 'POST',
    url: 'http://localhost/extjs_training/Demo_WebService/Utility.asmx/GetGenres',
    failure: function(response, options){
     Ext.get('my_id').dom.innerHTML = 'Load failed: ' + response.status;
    }
   }),
   reader: new Ext.data.JsonReader({
    fields: ['id', 'genre_name'],
    root: 'rows'
   }),
   listeners: {
          loadexception: function (proxy, options, response, e) {
              var result = response.responseText;
              Ext.MessageBox.alert('Load failure', e + " ..... " + result);
          }
      }
  });

  var loadSuccess = genres.load({
   callback: function(r, options, success){
    Ext.get('my_id').dom.innerHTML = 'Load status: success=' + success;
   }
  });
+1  A: 

Is the JSON you included above what is actually being returned from the call, or what you are anticipating it should look like? The string you included looks clean, but it looks like you formatted it as well. I'm not sure if the space after "id": is allowed, either. It might not be a big deal, though.

The missing parenthetical typically indicates that something in the JSON is wrong. It could be an extra character before/after the string. Use Firebug to examine what you are getting back, and make sure it is clear of any extra characters.

Jason
The JSON is cut and pasted from the loadexception is the ExtJS code shown
Chris Gill
I've removed the space after "id": and "sort_order": but still no luck
Chris Gill
Call off the dogs - it was me being stupid. My web service was wrapping the JSON with XML tags - the Ext.MessageBox.alert clearly hides this from the display. I'll work out what is wrong. Thanks for the help
Chris Gill
Cool, glad you figured it out. Stuff like that can be frustrating to find the first time. :)
Jason
A: 

Hi,

I am receiving the same error message pointing to jquery.jqGrid.min.js (line 10). Can't figure out for the life of me what I need to do to correct this. I am using jquery to fetch some data from my database and display the data in a grid.

Can neone help me please??

Mandeep