English 中文(简体)
为什么我能够从ExtJs4的服务器中接过JSON?
原标题:why I can t get JSON from server in ExtJs4?

我的大麻是从服务器上取得的。 这里是django服务器观测功能:

def showChart(request):
    data = [{"id":1, "name":"Tom", "email":"[email protected]"}, {"id":2, "name":"Bosh", "email":"[email protected]"}]
    return HttpResponse(json.dumps(data), mimetype="application/json");

很显然,显示Chart()将返回一名json。

我的前言之四

Ext.onReady(function() {
Ext.define( ProductionInfo , {
    extend:  Ext.data.Model ,
    fields: [ email ,  id ,  name ]
iii

var store_new = Ext.create( Ext.data.Store , {
    model:  ProductionInfo ,
    proxy: {
      type:  ajax ,
      url :  http://localhost:8000/production_data ,
      reader: {
          type:  json 
      }
    }
iii

store_new.load();
alert(store_new.getCount());

iii

但是,警报方言显示0,而正确的答案是2。 因此,我为什么能从服务器上接听过“智者”? (我可以通过GET在Chorme 和<0>提出请求获得正义之名)

问题回答

You could check my sample: https://github.com/lucassus/extjs4-account-manager It s rails application but json mechanism is very similar.

Basically you have to define a model with valid proxy: https://github.com/lucassus/extjs4-account-manager/blob/master/app/assets/javascripts/app/model/User.js
and a store which will have model attribute: https://github.com/lucassus/extjs4-account-manager/blob/master/app/assets/javascripts/app/store/Users.js





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签