$http get parameters does not work

kahonmlg picture kahonmlg · Jun 21, 2013 · Viewed 113.5k times · Source

Does anyone know why this does not work?

$http
    .get('accept.php', {
        source: link,
        category_id: category
    })
    .success(function (data, status) {
        $scope.info_show = data
    });

and this does work:

$http
    .get('accept.php?source=' + link + '&category_id=' + category)
    .success(function (data, status) {
        $scope.info_show = data
    });

Answer

dnc253 picture dnc253 · Jun 21, 2013

The 2nd parameter in the get call is a config object. You want something like this:

$http
    .get('accept.php', {
        params: {
            source: link,
            category_id: category
        }
     })
     .success(function (data,status) {
          $scope.info_show = data
     });

See the Arguments section of http://docs.angularjs.org/api/ng.$http for more detail