[英]post special char by ajax serializeArray()
I am trying to post whole form data by ajax. 我正在尝试通过ajax发布整个表单数据。 My sample code is here:
我的示例代码在这里:
$.ajax({
url: "@Url.Action("SaveTPGeneralInfo", "Techpack", new { area = "OMS" })",
data: $('#FormId').serializeArray(),
type: 'POST',
success: function (data) {
if (data) {
// .....
}
},
error: function (error) {
// .....
}
});
As I am working in asp.net mvc 4, I am catching the data like this: 当我在asp.net mvc 4中工作时,正在捕获如下数据:
public int SaveTPGeneralInfo(oms_techpack oms_techpack)
{
try
{
return 1;
}
catch (Exception ex)
{
return 0;
}
}
Here some data contains special characters (like &, @). 这里的一些数据包含特殊字符(如&,@)。 Those characters are passed as encrypted(like for '&' it passes 'amp;').
这些字符以加密方式传递(就像“&”一样,它传递“ amp;”)。 How can I get the original data that contains special characters.
如何获取包含特殊字符的原始数据。 Need help...
需要帮忙...
I create 2 methods that I run the result through to get back the original. 我创建2种方法,将结果运用于原始方法。
public string Decode(string value)
{
return (value)
.Replace(""", "\"")
.Replace("<", "<")
.Replace(">", ">")
.Replace("'", "&")
.Replace("@", "@");
}
public string Encode(string value)
{
return (value)
.Replace("\"", """)
.Replace("'", "''")
.Replace("<", "<")
.Replace(">", ">")
.Replace("&", "'")
.Replace("@", "@");
}
you can pass the string you want converted to one of these and you should get what you want. 您可以将要转换的字符串传递给其中之一,您应该得到想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.