Results 1 to 4 of 4

Thread: Synchronous AJAX requests?

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    55
    Vote Rating
    0
      0  

    Default 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
    101
      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
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    I would stay away from a sync request. Your app will freeze while it is pending.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

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