.net プロジェクトで Ajax を使用しています (MVC.net ではありません)。JScript 関数から .aspx.cs の関数を呼び出したいです。
これは私の JScript コードです:
$("a#showQuickSearch").click(function () {
if ($("#quick_search_controls").is(":hidden")) {
$.ajax({
type: "POST",
url: "Default.aspx/SetInfo",
data: "{showQuickSearch}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
alert(response.d);
}
});
$("#quick_search_controls").slideDown("slow");
$("#search_controls").hide();
$("#search").hide();
} else {
$("#quick_search_controls").hide();
}
});
そして、これは私の .aspx.cs 関数です:
[WebMethod]
public string SetInfo(string strChangeSession)
{
Label1.Text = strChangeSession;
return "This is a test";
}
問題は、.aspx.cs 関数が呼び出されておらず、label.text が更新されていないことです。