我阿賈克斯後不運行我的身後方法的代碼,因此不會返回任何數據被調用。代碼隱藏功能不被阿賈克斯POST
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="AspTest.Test" %>
Test.aspx文件(阿賈克斯腳本)
<script>
$(".avatarThumb").click(function() {
$.ajax({
type: "POST",
url: "Test.aspx/MyMethod",
//data: {"s": "Some data passed through" },
//contentType: 'application/json; charset=utf-8',
//dataType: 'json',
success: function (response) {
alert(response.d); //Returns "undefined"
},
failure: function(response) {
alert(response);
}
});
});
</script>
刪除的contentType和數據類型,則達到成功,但不運行代碼隱藏方法。在contentType和/或dataType處於活動狀態時,它不會達到成功或失敗。 FF螢火蟲不會顯示任何錯誤。
* Test.aspx.cs代碼隱藏方法
[System.Web.Services.WebMethod]
public static string MyMethod()
{
(*) Debug.WriteLine("MyMethod called!"); // (*) Breakpoint never reached
return "Method called!";
}
寫[HttpPost]。 – developer
@krillgar沒有結果,是'RUNAT = 「服務器」'甚至不允許呢?它不會在智能感知中彈出。 – Madmenyo
@developer我無權訪問該類。我需要'Microsoft.Activities.dll'。從未導入.dll,但我會嘗試。 – Madmenyo