how to pass xml as parameter using POST method and using jquery ajax

后端 未结 1 878
北恋
北恋 2020-12-29 10:39

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., \"\" as

相关标签:
1条回答
  • 2020-12-29 11:33

    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);
    
    0 讨论(0)
提交回复
热议问题