开发者

problems with passing html to the server with jquery

开发者 https://www.devze.com 2022-12-22 20:37 出处:网络
i have an ajax call $.ajax({ url: \'<%=Url.Action(\"SaveDetails\",\"Survey\") %>\', dataType: \'JSON\',

i have an ajax call

$.ajax({
                url: '<%=Url.Action("SaveDetails","Survey") %>',
                dataType: 'JSON',
                cache: false,
                data: { Id: selectedRow.Id, Value: surveyValue, FileName: filename, FileGuid: fileguid },
                success: function(data) {
                    ...
                }
            });

where the surveyValue is a html string. this call doesn't work. but is i chan开发者_StackOverflow社区ge the surveyValue to an ordinary text i works fine.

how can i pass the html to the server?


I'm guessing you'll need to encode it:

data: { ... Value: encodeURIComponent(surveyValue), ... }

And on the server side:

string value = Server.UrlDecode(surveyValue);
0

精彩评论

暂无评论...
验证码 换一张
取 消