Results 1 to 2 of 2

Thread: JsonP & writing data

  1. #1

    Default Answered: JsonP & writing data

    I'm attempting to both read and write data in an external database from a Sencha Touch App.
    I can't use a Json store with an ajax proxy because of cross-domain troubles, so I used a JsonP store defined as follows:


    Code:
    Ext.define('MyApp.store.JsonPShare', {
        extend: 'Ext.data.Store',
    
    
        requires: [
            'MyApp.model.Share',
            'Ext.data.proxy.JsonP',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json'
        ],
    
    
        config: {
            autoLoad: true,
            model: 'MyApp.model.Share',
            storeId: 'JsonPShare',
            proxy: {
                type: 'jsonp',
                api: {
                    create: 'http://localhost:8080/myapp/insert',
                    read: 'http://localhost:8080/myapp/select',
                    update: 'http://localhost:8080/myapp/update',
                    destroy: 'http://localhost:8080/myapp/delete'
                },
                reader: {
                    type: 'json',
                    rootProperty: 'data'
                },
                writer: {
                    type: 'json',
                    rootProperty: 'data'
                }
            }
        }
    });
    I can read data from the database, however, when I try to update a record through store.sync(), I get the error:


    Code:
    Uncaught Error: [ERROR][Ext.data.proxy.Server#create] JsonP proxies can only be used to read data.
    I have found that I can use the CORS mechanism to be able to use an ajax proxy, but I preferred to avoid it, is there an alternative?
    What is the better solution if my web-app will become an app?

  2. Yes, JSONP is really only for read-only use. I think your best bet is cors. Here's a site that might be helpful:
    http://enable-cors.org/

  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Yes, JSONP is really only for read-only use. I think your best bet is cors. Here's a site that might be helpful:
    http://enable-cors.org/

Similar Threads

  1. Response from writing store data
    By Michi_72 in forum Ext 5: Q&A
    Replies: 2
    Last Post: 23 Oct 2014, 2:26 PM
  2. Store Proxy Jsonp not working while Ext.data.JsonP.request does
    By kenono in forum Sencha Touch 2.x: Q&A
    Replies: 10
    Last Post: 31 Mar 2013, 9:30 AM
  3. Writing TreePanel data back to the store
    By gnube in forum Ext: Q&A
    Replies: 0
    Last Post: 28 Oct 2011, 11:58 PM
  4. Replies: 2
    Last Post: 22 Aug 2011, 4:22 AM
  5. Reading and writing directly to data store.
    By Johnbran in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 8 Jul 2011, 9:36 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •