Reputation:
I am using jQuery + ajax to post data to the server and facing issues when xml string is passed.
I want to pass xml string eg., "<test></test>
" as a parameter to the ajax function using POST method.
i am able to pass all other types, but not xml string.
Can somebody pls help me on this?
Upvotes: 13
Views: 18125
Reputation: 413
In order to post xml or html to the server, you first have to escape it and then decode on the server.
$.ajax({
type: "POST",
url: "Home/GetResults",
data: {
inputxml: escape('<test></test>')
},
success: function(msg) {
var data = JSON.parse(msg);
alert(data.Message);
},
});
on the server, you would then decode it by:
HttpUtility.UrlDecode(inputxml);
Upvotes: 18