AngularJS adding Headers in http.put request -


i new angularjs, right want use $http.put update json file @ remote repository.

but everytime try, following error

xmlhttprequest cannot load http://blabla&action=update.  no 'access-control-allow-origin' header present on requested resource. origin 'localhost:9080' therefore not allowed access.  

so doesn't work. did part of search on stack , google. lot of people saying should add headers. don't know how add headers correctly , have no idea how verify if headers correctly added.

can me? following code.

$http.defaults.headers.post['access-control-allow-origin'] = '*'; $http.defaults.headers.post['access-control-allow-methods'] = 'get, post, delete, put'; $http.defaults.headers.post['access-control-allow-credential'] = 'true'; $scope.update = function(key,value){     $scope.mydata[key] = value;     $http.put('http://blabla&action=update', $scope.mydata)     .success(function (data, status) {         alert('success');     }) 

the code above still giving me same error, research online, headers suppose solve problem... didn't. don't know did wrong. guys!

your main issue headers need set on server. error:

no 'access-control-allow-origin' header present on requested resource. origin 'localhost:9080' therefore not allowed access. key of this.

you requesting localhost:9080 somewhere foo.com/api. endpoint needs return access-control-allow-origin: localhost:9080 header application.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -