我所向往的美好 2022-03-04 16:18 采纳率: 100%
浏览 24
已结题

webfrom 利用ajax向后台传数据成功进入success,但是不调用webMethod

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
 <script>

                $(function () {
                    $("td input").click(function () {
                        var device = $(this).parent("div").siblings("div").children("marquee").text();
                        /*alert(device);*/

                        $.ajax({

                            type: "Post",
                            url: "小米商城.aspx/Getit",
                            //contenttype: "application/json; charset=utf-8",
                            data: {
                                "device": device
                            },
                            success: function (result,data) {
                                console.log("传入成功");
                            },
                            error: function (result) {
                                console.log("传入失败");
                            }


                        });
                    });
                })
            </script>

 [WebMethod] 
public static string Getit(string device)
        {
            Console.WriteLine("1231313");
           
            return "success";
           
        }

运行结果及报错内容

img

我的解答思路和尝试过的方法

看网上说加后台方法前加[webmethod] 定义为static ScriptManager设置EnablePageMethods="true"都试了,没用

我想要达到的结果
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 3月12日
    • 创建了问题 3月4日

    悬赏问题

    • ¥15 求一下解题思路,完全不懂
    • ¥15 tensorflow
    • ¥15 densenet网络结构中,特征以cat方式复用后是怎么进行误差回传的
    • ¥15 STM32G471芯片spi设置了8位,总是发送16位
    • ¥15 R语言并行计算beta-NTI中tree文件的类型
    • ¥15 如何解读marsbar导出的ROI数据?
    • ¥20 求友友协助弄一下基于STC89C52单片机的声光控制灯原理图
    • ¥15 arduino双向交通灯设计
    • ¥15 有没有会粒子群算法的大能(○゜ε^○)求带不会出收敛图😭
    • ¥15 Matlab读取根元素出错