Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:16:57+00:00 2026-06-09T23:16:57+00:00

What is the proper way of uploading the records via proxy type ‘jsonp’? I’m

  • 0

What is the proper way of uploading the records via proxy type ‘jsonp’?
I’m trying to sync() the store, with proxy type “jsonp’, but I get error message.

This is the model:

Ext.define("Sencha.model.User", {
    extend:"Ext.data.Model",
    //idProperty:"",


    config:{
        fields:[
            'userID',
            'userName',
            'userEmail'
        ],


        proxy: {
            type: 'jsonp',
                create  : 'http://domainname.com/users.php?action=insert',
                read    : 'http://domainname.com/users.php?action=fetchAll',
                update  : 'http://domainname.com/users.php?action=update',
                destroy : 'http://domainname.com/users.php?action=delete'
            },
            callbackKey: 'callback',
            reader: {
                type: 'json',
                rootProperty: 'Users',
                successProperty: 'success',
                messageProperty: 'message'
            },
            writer: {
                type: 'json',
                writeAllFields: false,
                encode: true
            }
        }
    }
});

The store:

Ext.define("Sencha.store.Users", {
    extend:"Ext.data.Store",
    config:{
        model:"Sencha.model.User",
        remoteFilter:false,
        remoteSort:true,
        autoLoad:true,
        }
    }
});

The store is updated:

Ext.getStore('Users').set('userName', 'Tom');

Now I’d like to update the record in database:

Ext.getStore('Objects').sync();

but I get the error:
Uncaught Error: [ERROR][Ext.data.proxy.Server#create] JsonP proxies can only be used to read data.

How can I update the record data – upload it to database via proxy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:16:58+00:00Added an answer on June 9, 2026 at 11:16 pm

    You are dealing with CORS (Cross Origin Resource Sharing) By default in all brwsers this is respected and all web servers are by default set to not allow CORS requests. More about CORS here

    If you are web developer, and have web server but you need access some external company API from javascript, easiest way is to setup your server to act as web proxy. Below are steps for some servers

    (Guru readers, feel free to add here more server configs since I proclamed this as wiki)

    Appache using mod_proxy and mod_proxy_http

    Open your virtual host file and add those lines (enable mod proxy foirst – further reading here)

    ProxyPass /proxy http://domainname.com/
    ProxyPassReverse /proxy http://domainname.com/
    

    Nginx

    If you are using NGIX for your app configarion add folowing lines

    location /proxy {
      proxy_pass        http://domainname.com/;
      proxy_set_header  X-Real-IP  $remote_addr; <-- maybe good to set
    }
    

    Further reading on this link.

    IIS

    If you are using IIS server

    the config is a bit more complex then those above but you can find all about it here

    For all above examples instead of using limited JSONP capabilities now you can use Ajax and JSON from response as you are serving that API on your server.


    Yes you can use it with Phonegap too with little effort

    I can say one thing at the biggining. You will either take blue pill or Red pill 🙂 I’m joing but there are two ways. One involes having, again, your own server with configuration as above and second is to dirty your hands with Phonegap native plugin.

    First approach (web server owners)

    Requires that you have your own web server. You will need above configs for mod_proxy so you can hide real service behind your service and proxy all HTTP requests from your phonegap app. You also have to include CORS (Cross Origin Resource Sharing) headers in response which is returned to phonegap app. Also consider to secure this with authentication since you are exposing content to world. Your phonegap app shold authenticate to your webservice, at least, trough basic HTTP auth over HTTPS.

    Follow this steps to complete setup:

    Apache

    On apache server, first enable modules “headers”

    $ a2enmod headers

    in virtual host file before or after proxy configuration add following:

    ProxyPass /proxy http://domainname.com/
    ProxyPassReverse /proxy http://domainname.com/
    # CORS allow to all
    Header set Access-Control-Allow-Origin *
    # Set basic authentication
    <Location /proxy>
      AuthType Basic
      AuthName "Restricted Area"
      AuthBasicProvider file
      AuthUserFile /usr/local/apache/passwd/passwords
      Require valid-user # setup user/password in file above using htpasswd
    </Location>
    

    In phonegap (Sencha Touch), for ajax request setup username and password like buffer.SlowBuffer();

    You’ll need first method to pack auth header

    function make_base_auth(user, password) {
      var tok = user + ':' + pass;
      var hash = Base64.encode(tok);
      return "Basic " + hash;
    }
    

    Then in your proxy set header like this

    headers : { Authorization : make_base_auth("some_username", "some_password") } // I know this is readable by other by you get the point.
    

    IIS 6

    To CORS-enable Microsoft IIS6, perform the following steps:

    1. Open Internet Information Service (IIS) Manager
    2. Right click the site you want to enable CORS for and go to Properties
    3. Change to the HTTP Headers tab
    4. In the Custom HTTP headers section, click Add
    5. Enter Access-Control-Allow-Origin as the header name
    6. Enter * as the header value
    7. Click Ok twice

    Optional, set basic auth, it’s straight forward process.

    IIS 7

    Also consider to check documentation which is mentioned above on how to set proxy and then amend that web.config file and add folowing

    <configuration>
     <system.webServer>
       <httpProtocol>
         <customHeaders>
           <add name="Access-Control-Allow-Origin" value="*" />
         </customHeaders>
       </httpProtocol>
     </system.webServer>
    </configuration>
    

    nginx

    In location append following

    if ($request_method = 'OPTIONS') {
    
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
    
        return 200;
     }
    
     if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
     }
    
     if ($request_method = 'GET') {
    
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
    
     }
    

    Google App engine can be helpfull too

    Since it is to long to fit in this box, I will provide link only to one blog where all is exlained properly

    The link

    …And what about the Second Approach

    Well it involves some native coding at least you will need phonegap plugin phonegap-proxy which you can find here But I’d avoid “native” since point of phonegap is to have multi platform app using single code… Oh, if you want to do your “special” plugin writing native code here is good example how to do same thing for facebook API

    It is now all up to you to decide which approach you will take 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

QUESTION: What is the proper way to use .get() in conjunction with .one() (or
What is the proper way to implement assignment by value for a reference type?
What is the proper way to get a first paragraph of the article for
What's the proper way to get DisplayMetrics, i.e. get screen/display info such as density
I can't get the proper way to upload a file on button click using
I was looking a proper way to implment a ScaleAnimation. My purpose is to
What's the proper way to add a literal text value from a field to
Is there a proper way, equation or technique in general to say, My web
What is the proper way to do the following in clojure? (ns todo.test.models.task (:use
Is there a proper way yet to unit test views with the aspx view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.