括号中的ExtJS - SyntaxError:missing) [英] ExtJS - SyntaxError: missing ) in parenthetical

查看:234
本文介绍了括号中的ExtJS - SyntaxError:missing)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些代码,以ExtJS的方式教育自己。我也是JSON的新手,希望这个问题很容易让你回答。我试图从一个基本的Web服务中检索一些基本的Web服务的数据,这些数据应该是将其结果作为JSON返回(看到我是新的JSON - 可能是破碎的)。 / p>

我收到的错误是$ b $中的


SyntaxError:missing) b括号


我从我的Web服务返回的JSON是

  {
rows:[
{
id:100000,
genre_name:Action b $ bsort_order:100000
},{
id:100002,
genre_name:喜剧,
sort_order 100002
},{
id:100001,
genre_name:戏剧,
sort_order:100001
}]
}

我的ExtJS代码如下。 $ loadexception callback是从

  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状态:success ='+ success;
}
});


解决方案

实际上是从通话中返回的,或者你期待的应该是什么样的?您所包含的字符串看起来很干净,但它看起来像您格式化。我不知道id之后的空格是否被允许。这可能不是什么大不了的。



丢失的括号通常表示JSON中的某些内容是错误的。字符串之前/之后可能是一个额外的字符。使用Firebug来检查你正在收回的内容,并确保没有任何额外的字符。


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;
    }
});

解决方案

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.

这篇关于括号中的ExtJS - SyntaxError:missing)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆