Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

XML string Ajax aspx

Assume i have very simple xml string, and i want to use Ajax JavaScript to send the xml string to Aspx web method using c#.
Can you show me how to do that?
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Hi,

$.ajax({
    url: your-url-here,
    data: "<test></test>", 
    type: 'POST',
    contentType: "text/xml",
    dataType: "xml",
    success : your-success-function,
    error : function (xhr, ajaxOptions, thrownError){  
        console.log(xhr.status);          
        console.log(thrownError);
    } 
}); 

Open in new window


On the backend side, you'll need a method that will accept a HTTP POST request with a string parameter. In this method, you'll have to parse your XML and do the required processing.
Avatar of ITsolutionWizard

ASKER

can you show me back end codes in mvc c#?
Hi,
You can have a look at the following article for XML deserialization:
http://www.janholinka.net/Blog/Article/11
The link is not even working. Have you reviewed it before posting here?
ASKER CERTIFIED SOLUTION
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial