我希望当我点击增量按钮时,点数会增加。我在服务器端代码中执行此操作,但在重新加载页面后它会增加。我希望它能够在不使用ajax和jquery重新加载页面的情况下执行此操作 这是我的代码
Deals.cs
[WebMethod]
[ScriptMethod]
public static string HOT(int DealPoints,int dealId)
{
DealPoints++;
int DealId = dealId;
int Points = DealPoints;
string retDeal = "";
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["FYP_Wish"].ToString()))
{
con.Open();
SqlCommand cmd = new SqlCommand("IncrementDeals", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DealPoints", SqlDbType.Int).Value = Points;
cmd.Parameters.Add("@DealId", SqlDbType.Int).Value = DealId;
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
int result = cmd.ExecuteNonQuery();
if (result == 1)
{
return "true";
}
con.Close();
return retDeal;
}
}
答案 0 :(得分:0)
试试这个:
$(document).ready(function(e) {
$("#btn1").click(function(e) { //btn1 is button id
var o = $(this).val();
o++;
$(this).val(o);
});
});