suchen

Heim  >  Fragen und Antworten  >  Hauptteil

angular.js - ANGULARJS HTTP.GET传值,后台收不到参数值

HTML:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<code><button type="submit" ng-click="get3(model.Name)">查询</button>

 

 

js:

$scope.get3 = function (name) {

        $http.get("/Movies/Search/" + name).success(function (data) {

            $scope.model = data;

        })

    }(这边name可以收到前台传过来的值)

 

MVC CONTROLLER:

public ActionResult Search(string Name)

        {

 

 

            var movie9 = db.Movies.Where(p => p.Name == Name);

            Movie movied = (Movie)movie9;

            return Json(new

            {

                Name = movied.Name,

                Genra = movied.Genra

 

            }, JsonRequestBehavior.AllowGet);

        }

</code>

(这边参数Name一直NULL,就是说,JS那边不能把值传过来)

我想大声告诉你我想大声告诉你2780 Tage vor754

Antworte allen(1)Ich werde antworten

  • 滿天的星座

    滿天的星座2017-05-15 16:51:26

    直接在浏览器输入 ../Movies/Search/xxxx 看看服务端有没有值,如果这样服务端还没有值,说明不是 Angular $http的问题,是你的ASP.NET MVC的路由设置有问题。

    Antwort
    0
  • StornierenAntwort