Extjs 4.2: How to send parameters properly in a Ext.Ajax.Request POST

mannuk picture mannuk · Jun 19, 2013 · Viewed 59.6k times · Source

I have to do a POST from my ExtJs script in order to delete something from my DB:

Ext.Ajax.request({
    url: 'deleteRole.html',
    method: 'POST',          
    headers: {'Content-Type': 'text/html'},
    waitTitle: 'Connecting',
    waitMsg: 'Sending data...',                                     
    params: {
        "rolename" : rolename
    },
    scope:this,
    success: received,                                    
    failure: function(){console.log('failure');}
});

when the post is sent i can see in the firebug the rolename in font but not as a param. I would like to show you another post (made with spring:form) relative to the user registration. If i inspect the post i can see the following:

image
(source: subirimagenes.com)

And i can get the parameters in my controller using @RequestParam.

But in the post that i have problems i can't see the parameters part, i can only see the Font(Fuente) part:

image2
(source: subirimagenes.com)

As a consequence, my spring controller does not detect any parameter. Is it something wrong in my POST?

Thank you

Answer

Reimius picture Reimius · Jun 19, 2013

The problem is that you are using the line headers: {'Content-Type': 'text/html'}, in your original question. This would set the content to text/html instead of the content being post data.