Alexander
Alexander

Reputation: 20234

Form submission (POST): Add get parameter

How can I define additional url parameters for my POST form submission?

This is how I load my form:

form.load({
    url:APIURI+'GetComment',
    method:'GET',
    params:params,
});

Result: The params object is serialized into GET parameters; the form content is returned as JSON.

This is how I submit my form:

form.submit({
    url:APIURI+'SetComment',
    method:'POST',
    params:params,
    callback:function() {
        me.close();
    }
});

Expected result: The form data should be sent as JSON POSTDATA, and the params should be sent as GET parameters.

Actual result: The form data was made an object; then the params were applied to that very object - and some of them overrode form fields which go by the same name.

What I also tried: I tried to put the params into the options object as urlParams, baseParams and extraParams, but none of these work.

Upvotes: 0

Views: 1391

Answers (1)

tonymayoral
tonymayoral

Reputation: 5217

You could serialize params and append the string to the url, such as:

form.submit({
  url: APIURI + 'SetComment?' + Ext.Object.toQueryString(params),
  method: 'POST',
  callback: function() {
    me.close();
  }
});

Upvotes: 1

Related Questions