3
をクリックして、私はそれがうまく働いていると私は代わりにdiv要素のボタンを交換するとき、それは全体をリフレッシュだのdivをクリックするとAJAX呼び出しシンプルなAJAX呼び出しは
の使用方法についての彼のウェブサイトからEncosia'sサンプルを使用しています私は火かき棒で何の誤りも見つけられません。ここで
は私のコードです:
スクリプト:
<script type="text/javascript">
$(document).ready(function() {
// Add the page method call as an onclick handler for the div.
$("#getdate").click(function() {
$.ajax({
type: "POST",
url: "Default.aspx/GetDate",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// Replace the div's content with the page method's return.
$("#Result").html(msg.d);
}
});
});
});
</script>
HTML:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<div id="Result">Click here for the time.</div>
<button id="getdate" value="Click Me">ClickMe</button>
コードビハインド:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Public Shared Function GetDate() As String
Return DateTime.Now.ToString()
End Function
。 – coder
私はそれが助けてうれしいよ:) – Andrey