1. #1
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default Can I make an ajax call to another server?

    Can I make an ajax call to another server?


    I am trying to call a centralized server for simple authentication purposes in an intranet environment. Can this be done, or does the call have to be in the same web root?

    Thanks for any advice.

    Code:
    Ext.Ajax.request({
        url: 'http://someserver/webservice/TestService',
        method: 'post',
        params: {
        username: a1ws23,
        password: 'testadm1n'
        },
     
        success: function(response, options) {     
             alert(response.responseText.trim());
        },
     
        failure: function(response, request) {
             alert('Failed - ' + response.status);
        }
    });
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    95
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You could use a ScriptTagProxy (or the cross-domain Ext.Ajax user extension).

    But be aware of the requirements for ScriptTagProxy (read the API docs carefully)!

  3. #3
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default Would you have a small example using ScriptTagProxy

    Would you have a small example using ScriptTagProxy


    Condor:

    Would you have a small example please?

    dlbjr
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  4. #4
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    look to feed-viewer example!
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    or the examples/form/custom.html example in your SDK

  6. #6
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default That will work Anomal - Thanks!

    That will work Anomal - Thanks!


    That will work Animal - Thanks!
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  7. #7
    Ext User
    Join Date
    Aug 2009
    Posts
    588
    Vote Rating
    1
    Mike Robinson is on a distinguished road

      0  

    Default


    What I usually do, for a variety of reasons, is to send all of the calls to one server, and if that server needs to "ask for help from someone else," then let it be the one to do it.

    The basic reason for this is ... timing. If you've got several different asynchronous request streams going on at the same time to different servers, then you can lose control of what's going on in a great big hurry. This creates software that's very, very difficult to debug ... stuff that's going to "fail in front of the end-user." Not what you want.

    Also... it's usually the case that the host-side components need to be aware of each other. They probably need a reliable, trustworthy way for "the left hand to know what the right hand is doing." Well, the client-side is neither reliable nor trustworthy.

    So... let there be a "single point of contact" for the client-side application to talk to. If there needs to be communication among server-side components, let them securely discuss things among themselves without further involving the client.

    It's not a matter of "is it possible to do it this-way or that." (The answer is, "yes.") It comes down to what is most likely to be most "RASS = Reliable, Available, Secure, Serviceable."

  8. #8
    Sencha User dlbjr's Avatar
    Join Date
    Oct 2007
    Location
    Cache, OK USA
    Posts
    281
    Vote Rating
    3
    dlbjr is on a distinguished road

      0  

    Default Needing ScriptTagProxy to return XML

    Needing ScriptTagProxy to return XML


    The code below should return JSON data. I am being forced to return XML.
    Can anyone give some advice on making this work? Thanks,

    Here is the XML being returned from the service:

    <read status="test" secure="false">
    <password>adm1n</password>
    <username>me</username>
    </read>



    Code:
    function loadApp() {
        var ds = new Ext.data.Store({
             proxy: new Ext.data.ScriptTagProxy({
             url: 'http://webservice/TestService',
             method: 'post',
             params: { username: me, password: 'adm1n' }
        }),
        reader: new Ext.data.JsonReader({
             root: 'data',
             id: 'username'
             Fields: [
                 { name: 'username', mapping: 'username', type: 'string' },
                 { name: 'password', mapping: 'password', type: 'string' }
            ]
        })
    });
     
    ds.load();
    }
    dlbjr - David L. Bryant Jr.

    Owner of
    dlbjr Technology Consulting
    Web2 System Developer & Consultant
    Focused on C.I. - Six Sigma - Shingo - Lean Technologies
    dlbjr.consulting@gmail.com

    Owner of:
    Attractive Graphics - "custom screen printing"
    attractivegraphicscsp@gmail.com

  9. #9
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    If you had taken Condor's advice you would realize that XML cannot be used.

    The name ScriptTagProxy gives a hint, and the documentation makes it explicit.

    A <script src="http://webservice/TestService?username=me&password=admin"></script> tag is added to the page.

    That's how you can talk to a "foreign" site.

    So obviously, as the documentation says, what must be returned is executable Javascript. Calling, as the documentation says, the specified callback function to inject the data into Ext.