WebForm 頁面ajax 請求后台頁面 方法


function ReturnOperation(InventoryID) {
             //入庫 接口
             if (confirm('你確認?')) {
                 $.ajax({
                     type: "post",
                     url: "xxx.aspx/InStorage",
                     data: "{InventoryID:'"+InventoryID+"'}",//注意,json 對象外面 加 雙引號  
                     contentType: "application/json",
                     dataType: "json",
                     success: function (r) {
                         if (r.d =="1") {
              alert("入庫成功");
                         } else {
                             alert("入庫失敗");
                         }
                     },
                     error: function (e) {
                         alert("錯誤是:" + e.responseText);
                     }
                 })
             } else {

             }
         }                

  這是前端code

    [WebMethod]  //注意添加引用,方法為靜態
    public static string InStorage(string InventoryID)
    {
  
       return InventoryID;
    }

這是xxx.aspx 頁面內的方法


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM