ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: zhouqi on November 26, 2020, 07:16:39 pm
-
When I config dataModel with "contentType: 'application/json'" as:
dataModel: {
location: 'remote',
url: '/news',
contentType: 'application/json; charset=UTF-8',
postData: {"author":"jack", "isTopic": 1},
dataType: 'JSON',
method: 'POST'
}
I found pqgrid ajax send data is "x-www-form-urlencoded" format (author=jack&isTopic=1), not JSON-String payload format ({"author":"jack", "isTopic": 1}).
In fact, ajax should send JSON-String payload format data use JSON.stringify(postData) when contentType is "application/json".
Now, I must config beforeSend to reset send data format:
beforeSend: function(xhr, settings) {
settings.data = JSON.stringify({....});
}
Is this a bug?
-
dataModel is dependent upon $.ajax to send remote requests.
setting contentType options sends only header without affecting the data format.
$.ajax works the same unless processData option is set to false.
https://api.jquery.com/jquery.ajax/
May be there is a need to add processData option to dataModel in order it to work as expected.