Author Topic: Bug? dataModel contentType=application/json, but postData send "k=v&k=v" format  (Read 170 times)

zhouqi

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 9
    • View Profile
When I config dataModel with "contentType: 'application/json'" as:

Code: [Select]
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:


Code: [Select]
beforeSend: function(xhr, settings) {
  settings.data = JSON.stringify({....});
}

Is this a bug?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4960
    • View Profile
[ Only Pro members may read this post. ]