这里是我的情况:我有一个UserBadge对象在ASP.NET中,它包含3个字段,作为一个User对象,Badge对象和boolean(isNotified),以检查用户是否已经通知赚取徽章.我在发送一个特定的问题,UserBadge从这个WebMethod():
[WebMethod()]
public static UserBadge Notify()
{
var db = new achievDb();
foreach (var uB in db.UserBadges)
{
if (System.Web.HttpContext.Current.User.Identity.Name == uB.User.UserName)
{
if (!uB.isNotified)
{
return uB;
}
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
对我的$.ajax:
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
url: "../NotifCodeBehind.aspx/Notify",
data: "{}",
complete: function (result) {
if (result) {
$("#notify").jGrowl("You've unlocked a badge!", { header: 'Yay', close: function () {
$.ajax({ …Run Code Online (Sandbox Code Playgroud)