SkipFire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2013
05:55 PM
Post with JSON
I've looked through docs and post and haven't found an answer yet, so how do I send JSON as part of a post request? The ParseJSON piece I need to use on the return shouldn't be a problem, but I have to submit JSON along with the post in order to get the JSON return. Below is a javascript version of what I need to do.
function GetData(requestType, requestValue) {
var Request = { RequestType: requestType, RequestValue: requestValue };
urlToHandler = 'JSONHandler.ashx';
jsonData = JSON.stringify(Request, null, 2);
$.ajax({
url: urlToHandler,
data: jsonData,
dataType: 'json',
type: 'POST',
contentType: 'application/json',
success: SuccessFunction,
error: function (data, status, jqXHR) {
alert('There was an error.');
}
});
}
function GetData(requestType, requestValue) {
var Request = { RequestType: requestType, RequestValue: requestValue };
urlToHandler = 'JSONHandler.ashx';
jsonData = JSON.stringify(Request, null, 2);
$.ajax({
url: urlToHandler,
data: jsonData,
dataType: 'json',
type: 'POST',
contentType: 'application/json',
success: SuccessFunction,
error: function (data, status, jqXHR) {
alert('There was an error.');
}
});
}