首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sench对string有反应吗?

Sench对string有反应吗?
EN

Stack Overflow用户
提问于 2014-01-08 12:05:33
回答 2查看 66关注 0票数 2

我在研究感官触觉。我用的是样品json url。我获得了一个成功的结果,但没有得到字符串的响应值。

我在这里使用代码:

代码语言:javascript
复制
Ext.data.JsonP.request({
       url : 'http://webapps.figleaf.com/arch101/dataservices/mobile/beer.cfc?method=getExcuses',
   method: 'GET',
    params: {
        },
    success: function(response) {
        // this will give you the JSON       
        Ext.Msg.alert('Success', response.responseText); 

    },
    failure: function(response) {         
     Ext.Msg.alert('Error', 'Please try again.', response.responseText);
}
});

我想得到以下响应

代码语言:javascript
复制
foo([
    {"EXCUSE":"I accidentally flushed my wallet down the toilet."},
    {"EXCUSE":"I ran out of water."},
    {"EXCUSE":"The Jets lost again"},
    {"EXCUSE":"I'm on a mission from God"},
    {"EXCUSE":"It was only one sheep..."},
    {"EXCUSE":"I think that I left my smartphone at your place"},
    {"EXCUSE":"My plants are all dying. I think they crave beer."},
    {"EXCUSE":"I need to listen to your Tito Puente albums."},
    {"EXCUSE":"I just found out that Darth Vader is Luke's father."},
    {"EXCUSE":"Sorry, I accidentally butt-dialed you. But since you have time to answer the phone, mind if I come over for a bit?"},
    {"EXCUSE":"I ran out of bacon and the stores are all out!"},
    {"EXCUSE":"Someone stole the cork from my lunch."},
    {"EXCUSE":"My girlfriend is preggers."},
    {"EXCUSE":"My girlfriend is preggers"},
    {"EXCUSE":"Yeast! If I don't get yeast within 30 minutes Ill suffer a brain aneurism."},
    {"EXCUSE":"I heard you had beer. Mind if I come over? I'm on my way over now, assuming you'll say yes. Thanks in advance!"},
    {"EXCUSE":"I heard you had beer. Mind if I come over? I'm on my way over now, assuming you'll say yes. Thanks in advance!"},
    {"EXCUSE":"You said tonight was our Battlestar Galactica marathon...?"},
    {"EXCUSE":"My parents are coming over."},
    {"EXCUSE":"I have plenty of bacon...but no beer. Can I come over?"},
    {"EXCUSE":"I left my iPhone 5 charger at my brothers and I don't have enough time to wait at the Apple store to get a new one."}
]) 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-08 12:43:32

好的,请使用这个:

代码语言:javascript
复制
success: function(response) {
    // this will give you the JSON       
    Ext.Msg.alert('Success', response[0].EXCUSE); 
},

响应将是数组本身。

票数 0
EN

Stack Overflow用户

发布于 2014-01-08 12:44:43

这是为我工作的:

代码语言:javascript
复制
Ext.data.JsonP.request({
    url: 'http://webapps.figleaf.com/arch101/dataservices/mobile/beer.cfc?method=getExcuses',
    method: 'get',

    success: function(response) {
        Ext.each(response, function(excuse) {
            console.log(excuse.EXCUSE);
        });
    },

    failure: function(response) {
        Ext.Msg.alert('Error', 'Please try again.', response.responseText);
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20995173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档