[CLOSED] How to make sync call using Ajaxproxy (Store)

  1. #1

    [CLOSED] How to make sync call using Ajaxproxy (Store)

    Hi,
    I have created a store with Ajaxproxy.
    Its working fine as it make the async call but as per our requirement I need to change it sync call.

     var storePositionBreakTarget = Html.X().Store().ID("UC085_LinearBreakTargets_Store_PositionBreakTarget").AutoLoad(true) 
            .Model(Html.X().Model()
                .Fields(
                 new ModelField("Key", ModelFieldType.String),
                 new ModelField("Name", ModelFieldType.String)
                )
             )
              .Proxy(Html.X().AjaxProxy()
                    
                     .Url(Url.Action("../LinearBreakTargets/FindBreakPositionCombination"))
                   
                     .Reader(Html.X().JsonReader().Root("data"))
             ).Listeners(L => L.Load.Fn = "ManageLBT.createPositionBreakType");
    Help will be appreciated

    Thanks
    Last edited by Daniil; Jul 08, 2014 at 5:23 AM. Reason: [CLOSED]
  2. #2
    Can you define what you mean by "sync" call? I'm not sure your definition of sync and our definition of sync would be the same.
    Geoffrey McGill
    Founder
  3. #3
    Thanks for the reply,

    Synchronous means that code execution will block (or wait) for the API call to return before continuing.
    as we have option to make it sync in JS need to implement same in ext.net

     Ext.create('Ext.data.Store', {
            id:'optionsStore',
            autoLoad: true,
            model: 'Options',
            async : false,
            proxy: {
                type: 'ajax',
                async : false,
                url: base_url+'dna2/form/get_options',  // url that will load data with respect to start and limit params
                noCache: false,
                reader: {
                    async:false,
                    type: 'json',
                    root: 'rows',
                    totalProperty: 'totalCount'
                }
                
            }  
        });
    Last edited by geoffrey.mcgill; Jun 30, 2014 at 5:41 PM.
  4. #4
    Hi @SaurabhGuptaNiit,

    I can suggest this solution:

    proxy: {
        type: "ajax",
        buildRequest: Ext.Function.createSequence(Ext.data.proxy.Ajax.prototype.buildRequest, function (operation) {
            operation.request.async = false;
            return operation.request;
        }),
        ...
    }
    Last edited by geoffrey.mcgill; Jun 30, 2014 at 1:46 PM.
  5. #5
    Can you provide more information about why a sync request is required and why an async one cannot be used?
    Sync requests is a bad practice and it should not be used in my opinion.

    Note: Starting with Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27), synchronous requests on the main thread have been deprecated due to the negative effects to the user experience.
    Last edited by Daniil; Oct 22, 2014 at 4:19 AM.

Similar Threads

  1. [CLOSED] Store Sync order of operations
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 14, 2013, 1:21 PM
  2. Replies: 0
    Last Post: Apr 27, 2013, 1:33 PM
  3. Sync store problem
    By Spamme in forum 2.x Help
    Replies: 1
    Last Post: Apr 18, 2013, 4:29 PM
  4. How to add mask for Store.sync()
    By devil in forum 2.x Help
    Replies: 2
    Last Post: Apr 01, 2013, 2:15 PM
  5. [CLOSED] REST store sync callback
    By thesvr in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 08, 2012, 12:57 PM

Tags for this Thread

Posting Permissions