我想使用Ajax调用C#函数,但调用不工作。脚本显示hello消息,但不显示成功/错误消息。我做错了什么Ajax调用c#函数不工作
Java脚本的
<script type="text/javascript">
$(document).ready(function() {
$('#btnsave1').click(function() {
alert("hello");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "LeaveSurrender.aspx/apply",
dataType: "json",
success: function() {
alert('Successfully Saved');
// window.location.href = "ClubCreation.aspx";
},
Error: function() {
alert('error');
}
});
});
});
C#方法
protected void apply()
{
MessageBox.Show("hi");
}
现在的作品,谢谢:) :) :) – techno
@techno? ??????? –
他打电话的方式既不需要公开也不必须是webmethod。 – afzalulh