2015-05-19 21 views
0
[WebMethod(EnableSession = true)] 
public static string SaveFavourites(string id, bool check) 
{ 
    //My Code here 
} 

此方法位於動態數據文件夾(DynamicData/CustomePages/Products)中。 我只是觸發ajax調用這個方法。如何使用c#在ASP.net的「動態數據」中添加Web方法

不幸的是它不工作。它返回我「404找不到」

在這裏我的ajax調用。

$.ajax(
     { 
      type: "POST", 
      url: "List.aspx/SaveFavourites", 
      contentType: "application/json; charset=utf-8", 
      dataType: "json", 
      async: true, 
      data: { "id": productID, "chkboxValue": chkboxValue }, 
      success: function (result) { 
       alert(result); 
      } 
     }); 

請儘快給予幫助。

+0

是你的頁面的名稱List.aspx? – Mairaj

+0

嘗試改變你的webmethod參數爲'SaveFavourites(string id,bool chkboxValue)' –

回答

0

看來你是不正確的網址在jquery ajax調用。

你的頁面是在哪裏寫的jquery ajax調用,在DynamicData/CustomePages/Products下?如果是,那麼你的網址是正確的,否則你必須把正確的網址。

提示:使用相對路徑。

相關問題