javascript - Angular js $http 404 call WebApi -
i'm trying call webservice using "$http". if call "$ajax" working ok.
example jquery $ajax working ok.
$.ajax({ type: "get", crossdomain: true, contenttype: "application/json; charset=utf-8", url: "http://localhost:60237/api/get/work", data: { cduser: 1}, datatype: "json", success: ondatareceived, error: ondataerror }); function ondatareceived(data) { } function ondataerror() { }
example angular $htpp (not working)
app.controller('alertxxcontroller', function ($scope, $http) { $http({ method: 'get', url: 'http://localhost:60237/api/get/work', params: 'cduser=1' }).success(function (data) { alert("ok"); }).error(function () { alert("error"); }); });
really not know why not calling. can't identify error, return 404 (not found).
i think "params" option wrong.
try this:
$http({ method: 'get', url: 'http://localhost:60237/api/get/work', params: { cduser: 1} }).success(function (data) { alert("ok"); }).error(function () { alert("error"); }); });
Comments
Post a Comment