Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 Jquery和Ajax调用无法正常工作_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 Jquery和Ajax调用无法正常工作

Asp.net mvc 3 Jquery和Ajax调用无法正常工作,asp.net-mvc-3,Asp.net Mvc 3,您好,我正在尝试显示选项卡并尝试获取选项卡的数据,使用下面的代码,我成功地显示了选项卡,但我的控制器中未调用GetManufacturerProductsForCountry操作。如果我的代码正在运行,请纠正我 " %> var taskInput=“”; $.ajax({ url:“/Manufacturers/GetManufacturerProductsForCountry/”++, 键入:“get”, 成功:功能(数据){ 任务输入=数据; $(“#ProductCount

您好,我正在尝试显示选项卡并尝试获取选项卡的数据,使用下面的代码,我成功地显示了选项卡,但我的控制器中未调用GetManufacturerProductsForCountry操作。如果我的代码正在运行,请纠正我

" %>


  • var taskInput=“”; $.ajax({ url:“/Manufacturers/GetManufacturerProductsForCountry/”++, 键入:“get”, 成功:功能(数据){ 任务输入=数据; $(“#ProductCountry”).html(数据); } });

    我建议在页面上调用ajax一次,然后为每个页面插入html。太多的ajax调用可能不起作用,我相信这是有限制的

    如果成功,请在“> 与$(“#ProductCountry”).html(数据)不匹配


    此外,出于安全考虑,在MVC中默认情况下,您不能执行ajax GET,而应该使用[HttpPost]来修饰控制器方法,并在ajax调用中指定该方法。

    在jQuery对象中,该id似乎是错误的

    试一试

           $("[id*=" + "ProductCountry" + "]").html(data);
    
    而不是

             $("#ProductCountry").html(data);
    
           $("[id*=" + "ProductCountry" + "]").html(data);
    
             $("#ProductCountry").html(data);