2
我正在使用jquery ajax方法并从该方法向asp页面方法发送电子邮件,但得到无效的Json基元错误我已经使用followind代码如果有人知道如何处理这个问题,请帮助。无效的JSON基元:从jquery ajax方法获取asp.net中的发布值时出错
$.ajax({
url: "login.aspx/DNSValidation",
type: 'POST',
cache: false,
dataType: 'json',
data: {"EmailAddress":email.toString()},
contentType: "application/json; charset=utf-8",
timeout: 6000,
error: function() {
alert('AJAX Request Failed');
ajaxInProgress = false;
},
success: function (responseData) {
Console.debug("Email : " + responseData.d);
ajaxInProgress = false;
}
}); //ajax
login.aspx的页面代码
[WebMethod]
public static string DNSValidation(object EmailAddress)
{
List<object> eMail = new JavaScriptSerializer().ConvertToType<List<object>>(EmailAddress);
Address product = new Address();
product.emailaddress = eMail[0].ToString();
string output = JsonConvert.SerializeObject(product);
return output;
}