Results 1 to 7 of 7

Thread: Problem using JSON POST within Ajax proxy

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    4

    Question Answered: Problem using JSON POST within Ajax proxy

    Hi there,
    I'm messing arround with JSON requests. Here what i've got working: (sorry if the src is a little crappy, refactore after test... probably)

    Code:
    Ext.Ajax.request({    url: 'http://myWeb/Service/method/',
    
    
        method: 'POST',
        headers: {
            'Content-Type': 'application/json;charset=utf-8'
        },
        //data: data,     
        params: JSON.stringify({
                parentLevelID: 0,
                parentID: 0,
                top: 10,
                localizationKzID: 'DE'
             }),
        failure: function (response) {console.log(response);},
        success: function (response, opts) {console.log(response);}
    });
    This works just as it should. But of course i want to use fancy stores and such, and so this is what i wrote (at least it's the current state):

    Code:
    var storep = new Ext.data.Store({
        model  : 'ChildLevelResult',
        autoLoad	: true,
        proxy: {
        	type	: 'ajax',
        	url		: 'http://myWeb/Service/method/',
        	noCache: false,
        	limitParam: '',
        	useNull: true,
        	headers: {
            	'Content-Type': 'application/json;charset=utf-8'
        	},
        	actionMethods: {
    	        create : 'POST',
    	        read   : 'POST',
    	        update : 'POST',
    	        destroy: 'POST'
    	        },
        	reader	: {
        		type	: 'json',
        		encode	: 'false',
        		root	: 'ChildLevelResult',
    	       },
       		extraParams: JSON.stringify({
                parentLevelID: 0,
                parentID: 0,
                top: 10,
                localizationKzID: 'DE'
             }),
           },
     });
    This fails
    According to Chrome the "Request Payload" of the FIRST, working query is:
    Code:
    {"parentLevelID":0,"parentID":0,"top":10,"localizationKzID":"DE"}
    And the "Request Payload" of the SECOND, not working query is:
    Code:
    0=%7B&1=%22&2=p&3=a&4=r&5=e&6=n&7=t&8=L&9=e&10=v&11=e&12=l&13=I&14=D&15=%22&16=%3A&17=0&18=%2C&19=%22&20=p&21=a&22=r&23=e&24=n&25=t&26=I&27=D&28=%22&29=%3A&30=0&31=%2C&32=%22&33=t&34=o&35=p&36=%22&37=%3A&38=1&39=0&40=%2C&41=%22&42=l&43=o&44=c&45=a&46=l&47=i&48=z&49=a&50=t&51=i&52=o&53=n&54=K&55=z&56=I&57=D&58=%22&59=%3A&60=%22&61=D&62=E&63=%22&64=%7D
    Seems as if every Character ist send with an index... This makes me crazy - i don't have a clue haw to fix this.
    Do you?
    Thanks in advance for your help!

  2. Hi,
    Have you resolved this? I'm facing the exact same problem - and 4+ hours now scavenging for a solution! GWT is looking increasingly tempting at this point....

    Quote Originally Posted by KITS_MSC View Post
    Hi Andrea Cammarata,
    thanks for your reply!
    While trying different things I switched to JSON.stringify. Without it the following Request Payload is sent:

    Code:
    parentLevelID=0&parentID=0&top=10&localizationKzID=DE
    These looks look like GET Parameters, but not POST.

    I'm not sure about your second question. The second request is fired manually by storep.load() - if that is what you have asked for.

  3. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    4

    Default

    No clue anybody? Is anybody able to reproduce this, at least? I can hardly believe nobody stumbled upon this before.

  4. #3
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Answers
    148

    Default

    Hi KITS_MSC.
    Just a question.
    Why are you using JSON.stringify on your extraParams config?
    You can simply write

    Code:
    extraParams: {
         parentLevelID: 0,     parentID: 0,
         top: 10,
         localizationKzID: 'DE'
    }
    And another question:
    When your second request is performed?
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  5. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    4

    Default

    Hi Andrea Cammarata,
    thanks for your reply!
    While trying different things I switched to JSON.stringify. Without it the following Request Payload is sent:

    Code:
    parentLevelID=0&parentID=0&top=10&localizationKzID=DE
    These looks look like GET Parameters, but not POST.

    I'm not sure about your second question. The second request is fired manually by storep.load() - if that is what you have asked for.

  6. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    1
    Answers
    1

    Default

    Hi,
    Have you resolved this? I'm facing the exact same problem - and 4+ hours now scavenging for a solution! GWT is looking increasingly tempting at this point....

    Quote Originally Posted by KITS_MSC View Post
    Hi Andrea Cammarata,
    thanks for your reply!
    While trying different things I switched to JSON.stringify. Without it the following Request Payload is sent:

    Code:
    parentLevelID=0&parentID=0&top=10&localizationKzID=DE
    These looks look like GET Parameters, but not POST.

    I'm not sure about your second question. The second request is fired manually by storep.load() - if that is what you have asked for.

  7. #6
    Sencha User
    Join Date
    Nov 2011
    Posts
    4

    Default

    Hi PradeepPai,
    we "solved" this issue by switching our service to GET. Thar was possible to us because we didn't really need POST. Switching was much easier than going deeper into sencha. IMHO this is a bug - perhaps it will be solved in Version 2 - I didn't check this out.

    Sorry I don't have a suitable solution for you.

  8. #7

    Default

    Hi anybody Solved this . I am having exactly same issue.

Tags for this Thread

Posting Permissions

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