【发布时间】:2011-08-16 15:27:12
【问题描述】:
我的 jquery ajax 函数没有调用 webmethod。 jquery 函数返回 web 服务页面的 html。 函数不明白“ebulten_add”是一个webmethod!
"url:ajaxPage.aspx/e_bulten"
写webmethod名字或者不写都是一样的..都返回ajaxPage.aspx html。
$.ajax({
type: "POST",
url: 'ajaxPage.aspx/ebulten_Add',
data: "{ebEmail:'" + Ebemail + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$("#span_result").hide();
$("#span_spinner").hide();
$("#span_result").html(result.d).fadeIn();
},
error: function (msg) {
$("#span_result").hide();
$("#span_spinner").hide();
$("#span_result").html("Lütfen tekrar deneyin.").fadeIn();
}
});`
ajaxPage.aspx 中的 web 方法
[System.Web.Services.WebMethod]
public static string ebulten_Add(string ebEmail)
{
if (ebEmail == "Email")
{
return "*Bilgilerinizi Girmediniz";
}
else
{
List<ListItem> ebList = new List<ListItem>();
ebList.Add(new ListItem("@Eb_email", ebEmail));
BL.Atom.GetByVoid("spEbulten_Add", ebList);
return "*E-Bülten kaydınız başarıyla tamamlanmıştır";
}
}
【问题讨论】:
标签: c# web-services jquery webmethod