Angular JS AJAX Call with Parameters

ajax, angularjs, asp.net-mvc, javascript, parameters

Solution

Since it's a GET request you shouldn't be sending data. You need to be sending a query string.

Change your `data` to `params`.

$http({
    method: "GET",
    url: url + "/dataEntry/test",
    params: {
        sampletext : "sample"
    }
})

Source: http://docs.angularjs.org/api/ng/service/$http

Problem

without the parameters of the method Get, the code works, but if the method asks for a parameter an error 404 is returned. How do I properly send parameters with Angular JS? ``` factory.test = function () { var q = $q.defer(); $http({ method: "GET", url: url + "/dataEntry/test", data: { sampletext : "sample" } }) .success(function (data, status, headers, config) { q.resolve(data); }) .error(function (data, status, headers, config) { q.reject(data); }); return q.promise; }; ``` ``` [Route("test")] public String Get(string sampletext) { return "Reply coming from data entry controller" + sampletext; } ```

Original source