Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know that the variable 'LastSelectedSettingValue' will sometimes contain html tags.
When it is simple text the JSON below works fine. When it contains HTML the JSON below fails. I have tried JSON.Encode() and other things, but without success.

SQL
$.ajax({
               url: '/StoreAdmin01/UpdateSetting',
               type: 'POST',
               dataType: "json",
               traditional: true,
               async: false,
               data: { settingId: LastSelectedSettingIdValue, settingValue: LastSelectedSettingValue, time: new Date() },
               success: function (result) {
               },

               error: function () {
                   alert("error");

               }
           });
Posted

1 solution

Use Base64 transcoder to encode your string:
https://code.google.com/p/javascriptbase64/[^]
Like this:
JavaScript
Base64.encode('yourvalue') 

In Server side, use:
C#
byte[] b = Convert.FromBase64String(yourpostedvalue);
string yourvalue = System .Text.Encoding.UTF8.GetString(b);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900