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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -