POST json data

POST json data

OneMHzOneMHz Posts: 3Questions: 0Answers: 0
edited October 2012 in General
I'm trying to use ASP.Net web services for the data source. The problem I'm having is that my web services expect the data in JSON format. But the only way I can use your methods to post is in query string format. So, instead of my post looking like this:
[code]
{"wsParameter": { "ID": 1001, "Name": "Some Guy", "Address": "123 Main St" } }
[/code]

It looks like this
[code]
wsParameter=%7B%22ID%22%3A%221001%22%2C%22Name%22%3A%22Some%20Guy%22%2C%22Address%22%3A%22123%20Main%20St%22%3A%7D%7D
[/code]

Does anyone have a workaround to get this to post JSON format?

(PS: I had to modify the script a little because you have to pass a content type header "contentType": "application/json; charset=utf-8" to $.ajax for ASP.Net web services to work at all. But so far, I can only figure out post calls without data.)

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    > Does anyone have a workaround to get this to post JSON format?

    You would need to use the fnSeverData option to override the default DataTables Ajax send (which sends the parameters by basic HTTP GET / POST, not wrapping them up into a JSON object) to have it do what you need.

    Allan
This discussion has been closed.