1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    55
    Vote Rating
    0
    vvatikiotis is on a distinguished road

      0  

    Default Unanswered: Synchronous AJAX requests?

    Unanswered: Synchronous AJAX requests?


    I need to send several POST requests so that my app fires each request only when the response of the previous request has been received.

    In Ext 4.1.1 there is an async property for Ext.data.Connection. http://www.sencha.com/forum/showthre...ght=async+ajax

    Is there anything similar in ST2?

  2. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    I've had to get around this by just calling the next Ext.Ajax.request in the success of the previous.

    In the docs, it says that Ext.data.Connection: "Requests made by this class are asynchronous, and will return immediately"

    I haven't found anything that allows it to behave like you are asking.

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Answers
    5
    Vote Rating
    10
    pepperseb is on a distinguished road

      0  

    Default


    Doing an ext.Ajax.request, you can also use the async parameter even though it's not in the docs. I tested it and it works.

    Code:
    async: false
    But you'd better follow jerome's idea (using callbacks) as synchronous request means the request will block the JS thread (and usually the browser too), giving a poor user experience.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    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


    I would stay away from a sync request. Your app will freeze while it is pending.
    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.