传入的对象无效,应为“:”或“}”。
如果出现了上面这个错误,应该是json格式的问题,也许是json里有url导致的吧。
解决办法:
1.客户端:发送json之前将json编码,
jsonContent = encodeURIComponent(jsonContent);
而且json数据必须用双引号(切记)。
2.WebService:
[WebMethod]
public static string SendEmail(string email, string jsonContent)
{
jsonContent = new Reports().DecodeUrl(jsonContent);//这里无法调用Server.UrlDecode,所以另写了个public方法。
return "success";
}
public string DecodeUrl(string s)
{
return Server.UrlDecode(s);
}