Results 1 to 8 of 8

Thread: [Solved] Getting the contents of an URL as a string

  1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    35

    Default [Solved] Getting the contents of an URL as a string

    Hi gang -

    As part of my arduous process of converting our app from Dojo to Ext, I need the ability to get the contents of an URL (on the same server) back as a string. Of course I could write it from scratch, but I was wondering if: 1. this functionality already exists in the kit somewhere, and 2. if it doesn't, is there an existing I/O API I could leverage?

    Any/all help appreciated.

    thx,
    -d.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    You might start with the Ajax class. http://extjs.com/deploy/dev/docs/?class=Ext.Ajax

  3. #3

    Default

    are you talking about doing a simple xhr request like this?
    PHP Code:
    Ext.Ajax.request({
      
    url 'handler.php',
      
    params : { param1 "dosomething" },
      
    success : function(transport){
        var 
    text transport.responseText//if you just want the result as a string
        
    var obj Ext.decode(transport.responseText); //if you wanted to turn json into an object
      
    }
    }); 

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    35

    Default

    Perfection.

    You guys are the best!

  5. #5
    Sencha User
    Join Date
    Sep 2007
    Posts
    35

    Default

    One additional follow-up question if you guys would indulge me. Is there any way to force this call to SYNC? If there is, I don't see it in the API - which is surprising because a generic XHR can be either.

    thx,
    -d.

  6. #6

    Default

    i believe it is possible, but is considered bad practice unless there is absolutely no other way to do what you want (something which i have yet to see a real world case for).

  7. #7

  8. #8
    Sencha User
    Join Date
    Sep 2007
    Posts
    35

    Default

    Quote Originally Posted by devnull View Post
    i believe it is possible, but is considered bad practice unless there is absolutely no other way to do what you want (something which i have yet to see a real world case for).
    It's not that there's NO other way to do it. We are dynamically loading javascript modules, and we've found in the past that SYNC was the most viable approach.

    best,
    -d.

Posting Permissions

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