1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    53
    Vote Rating
    0
    vmadman is on a distinguished road

      0  

    Default AjaxProxy

    AjaxProxy


    Man, this makes me feel pretty dumb, but I cannot seem to find an answer anywhere.

    It seems like it would be written somewhere obvious and I am just overlooking it.

    Code:
    	Ext.regModel('country', {
    		fields: ['country_id', 'name', .. ],
    		proxy: {
    			type: 'ajax',
    			url: 'index.php?controller=json&model=country',
    			reader: {
    				type: 'json',
    				root: 'country'
    			},
    			writer: {
    				type: 'json',
    				encode: false,
    				root: 'country'
    			}
    		}
    	});
    
    	var country = Ext.ModelMgr.getModel('country');
    
    	country.load(123, {
    		success: function(country){
    			console.dir(country);
    		}
    	});
    What's weird to me is that in the generated request the param for 'read' does not exist, and the param for 'id' does not exist. That is to say, nothing sent to my server API says 'read' or '123'.

    Another thing, it seems kinda weird that I need to specify "model=" in my base URL, I figured that sort of information could be auto-inserted somehow. But if that was my only worry, I'd feel pretty good.

    Every example on the topic that I could find seems to prefer RESTful stores, which.. is not something I'm used to with PHP. I just need that proxy to tell my server what it wants to do.

    Anyone know where I'm going wrong?

    Thanks,
    Luke

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Question Missing xaction when using AjaxProxy

    Missing xaction when using AjaxProxy


    Hi all,

    I got the same issue as Luke, I cant find the xaction (as it was called in ext3) paramater in any request made by an AjaxProxy. I have made a (dirty) hack to include it in data.ServerProxy.buildRequest, although I dont feel this is the right place to fix this. (Don't had much time to jump into the source)

    Anyone has any ideas on this issue? Am I missing some way to differentate between the different CRUD requests?

    Code:
        buildRequest: function(operation) {
            var params = Ext.applyIf(operation.params || {}, this.extraParams || {});
            
            //copy any sorters, filters etc into the params so they can be sent over the wire
            params = Ext.applyIf(params, this.getParams(params, operation));
    		
    	params.xaction = operation.action;        /// <<<===
            var request = Ext.create('Ext.data.Request', {
                params   : params,
                action   : operation.action,
                records  : operation.records,
                operation: operation
            });
            
            request.url = this.buildUrl(request);
            
            /*
             * Save the request on the Operation. Operations don't usually care about Request and Response data, but in the
             * ServerProxy and any of its subclasses we add both request and response as they may be useful for further processing
             */
            operation.request = request;
            
            return request;
        }
    Last edited by flanders; 6 Mar 2011 at 11:06 AM. Reason: clarified which code was added

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    53
    Vote Rating
    0
    vmadman is on a distinguished road

      0  

    Default


    wow.. no response..

    This is just baffling, no one knows this? It seems like this would be "Question 1" in any FAQ on the Ext JS 4 data package.

    I ended up extending AjaxProxy with my own proxy but I can't help but think that I am going down the wrong path in doing that.

    I set loads of breakpoints. I do not see where ServerProxy or AjaxProxy make any sort of effort AT ALL to append mode or id to the URL for read operations (as GET).

    I have trouble understanding how any API could work without that sort of information.

    Oh well, guess I'll just run with my subclass.

    Thanks,
    Luke

  4. #4
    Sencha User
    Join Date
    Feb 2010
    Posts
    15
    Vote Rating
    0
    idal is on a distinguished road

      0  

    Default


    I have exactly the same problem, it is unfortunate that we must start from 0 at each change of version and the documentation is not a bit more talkative about these changes.

  5. #5
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    5
    Vote Rating
    0
    alixon is on a distinguished road

      0  

    Default xaction as get parameter

    xaction as get parameter


    We helped ourselves with adding the following api to the proxy:
    Code:
           api: {
              create  : '?xaction=create',
              read    : '?xaction=read',
              update  : '?xaction=update',
              destroy : '?xaction=destroy'
            }
    this results in sending the xaction as get parameter.

Similar Threads

  1. AjaxProxy with jsonData option?
    By Greendrake in forum Ext: Discussion
    Replies: 5
    Last Post: 5 Dec 2012, 1:44 PM
  2. AjaxProxy on failure
    By h4m1d.r3z4 in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 30 Jan 2011, 2:50 AM
  3. Client Cached or Buffered AjaxProxy
    By danmux in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 24 Jan 2011, 1:59 PM
  4. [FIXED-126] Issues using AjaxProxy / Store / XmlReader
    By bone in forum Sencha Touch 1.x: Bugs
    Replies: 7
    Last Post: 14 Dec 2010, 10:40 AM
  5. AjaxProxy 'POST' method ?!
    By AndreaCammarata in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 14 Oct 2010, 11:02 PM

Thread Participants: 3