tags:

views:

2513

answers:

2

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?

+4  A: 

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);
ryanrdl
A: 

nice answer

thanks

c2project