zoukankan      html  css  js  c++  java
  • sencha touch jsonp

    asp.net server side code 

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
                
    String jsonString = "{success: true}";
    jsonString=@"{users: [
        { id: 1, firstName: 'Tommy laptop', lastName: 'Maintz' },
        { id: 2, firstName: 'Rob', lastName: 'Dougan' },
        { id: 3, firstName: 'Ed', lastName: 'Avins' },
        { id: 4, firstName: 'Jamie laptop', lastName: 'Avins' },
        { id: 5, firstName: 'Dave', lastName: 'Dougan' },
        { id: 6, firstName: 'Abraham', lastName: 'Elias' },
        { id: 7, firstName: 'Jacky', lastName: 'Ngyuyen' },
        { id: 8, firstName: 'Jay', lastName: 'Ngyuyen' },
        { id: 9, firstName: 'Jay', lastName: 'Robinson' },
        { id: 10, firstName: 'Rob', lastName: 'Avins' },
        { id: 11, firstName: 'Ed', lastName: 'Dougan' },
        { id: 12, firstName: 'Jamie', lastName: 'Poulden' },
        { id: 13, firstName: 'Dave', lastName: 'Spencer' },
        { id: 14, firstName: 'Abraham', lastName: 'Avins' },
        { id: 15, firstName: 'Jacky', lastName: 'Avins' },
        { id: 16, firstName: 'Rob', lastName: 'Kaneda' },
        { id: 17, firstName: 'Ed', lastName: 'Elias' },
        { id: 18, firstName: 'Tommy', lastName: 'Dougan' },
        { id: 19, firstName: 'Rob', lastName: 'Robinson' }
    ]}";
    String cb = Request.Params.Get("callback");
    String responseString = "";
    if (!String.IsNullOrEmpty(cb)) {
        responseString = cb + "(" + jsonString + ")";
    } else {
        responseString = jsonString;
    }
    Response.Write(responseString);
    
    
        }
    </script>

    js:

    Ext.define('MyApp.store.MyJsonPStore', {
        extend: 'Ext.data.Store',
    
        requires: [
            'MyApp.model.Person',
            'Ext.data.proxy.JsonP',
            'Ext.data.reader.Json'
        ],
    
        config: {
            autoLoad: true,
            data: [
                {
                    id: 268,
                    firstName: 'Lewis',
                    lastName: 'Wright'
                },
                {
                    id: 557,
                    firstName: 'Beulah',
                    lastName: 'Sanchez'
                },
                {
                    id: 983,
                    firstName: 'Leon',
                    lastName: 'Martin'
                }
            ],
            groupField: 'lastName',
            model: 'MyApp.model.Person',
            storeId: 'MyJsonPStore',
            proxy: {
                type: 'jsonp',
                url: 'http://www.abc.com/jsonp.aspx',
                reader: {
                    type: 'json',
                    rootProperty: 'users'
                }
            }
        }
    });

     reference:

    http://docs.sencha.com/touch/2.3.1/#!/api/Ext.data.proxy.JsonP

  • 相关阅读:
    ios学习记录 day45 UI21 特效动画
    ios学习记录 day44 UI20 Storyboard 高级可视化编程 + 单例
    ios学习记录 day43 UI19 标签视图 和 block用法
    ios学习记录 day42 UI18 集合视图
    ios学习记录 day41 UI17 多线程
    7-2 How Many Ways to Buy a Piece of Land (25 分)
    7-1 Panda and PP Milk (20 分)
    1146 Topological Order (25 分)
    1089 Insert or Merge (25 分) 归并排序
    1098 Insertion or Heap Sort (25 分) 堆
  • 原文地址:https://www.cnblogs.com/zyip/p/3525492.html
Copyright © 2011-2022 走看看