1. #1
    Sencha Premium Member
    Join Date
    May 2009
    Posts
    157
    Vote Rating
    9
    ZachG will become famous soon enough

      0  

    Default Using Ext.Ajax.request for a file on another website

    Using Ext.Ajax.request for a file on another website


    I want to retrieve some data from another site and use it locally, but when I specify the url parameter of Ext.Ajax.request, the request is never issued.

    Code:
    Ext.Ajax.request({
         url:"https://twitter.com/goodies/list_of_lists?screen_name=zgardnerallofe",
         callback:function(inOptions, inSuccess, inResponse) {
              debugger;
         }
    });
    When I look at firebug, it looks like the request was never issued. Is there some other variable that I need to turn on or something, or was this done by design?

    The easy way to get around it was to have it load from a local PHP file which did a file_get_contents of the URL, but this seems like unnecessary overhead when JS could do it directly.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,994
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    It's just that loading something from another domain has more coding. You have to use a proxy like ScriptTagProxy
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

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

      0  

    Default


    Browsers generally will not load material from more than one site at a time. (This is an erstwhile "security" feature, of dubious merit IMHO.) But you can easily arrange for a server to obtain the material by those means, and "relay" it to the client.

  4. #4
    Ext User
    Join Date
    Feb 2010
    Posts
    4
    Vote Rating
    0
    Swat is on a distinguished road

      0  

    Default


    Hi, I want to make http ajax request to other server, url works fine inany browser and returns status as "400" with output. But if I make ajax request to the same gives me communication failure message and in firebug the request status shows as "404" bad request. has anyone come across such situation and got the solution? please do let me know.
    thanks.

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,895
    Vote Rating
    623
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Do a google search for cross domain policy.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Ext User
    Join Date
    Feb 2010
    Posts
    4
    Vote Rating
    0
    Swat is on a distinguished road

      0  

    Default


    Thanks for reply. I know about cross domain policy. But here question is not about the policies. I want to display the results by making ajax calls to other server without any server side code and of course without any policy file.

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,895
    Vote Rating
    623
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    That's the point. If you read the stuff about cross domain policy, you would know it's not possible, it's a security restriction imposed by the browser.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  8. #8
    Ext User
    Join Date
    Feb 2010
    Posts
    4
    Vote Rating
    0
    Swat is on a distinguished road

      0  

    Default


    Hi, Actually I was going through similar posts and found this http://www.extjs.com/forum/showthread.php?t=17691
    I have not tried the example.
    Thanks

  9. #9
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,895
    Vote Rating
    623
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Yes, but like the ScriptTagProxy it requires the data from the server to wrapped in a JS method that can be executed. Unless Twitter happens to have an API that sends data in that format, you can't do it.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  10. #10
    Ext User
    Join Date
    Feb 2010
    Posts
    4
    Vote Rating
    0
    Swat is on a distinguished road

      0  

    Default


    hmmm...