Skip to content

Instantly share code, notes, and snippets.

@rubinchyk
Created November 21, 2016 09:48
Show Gist options
  • Save rubinchyk/79bc8eb1bcd861078027c7dfa999058c to your computer and use it in GitHub Desktop.
Save rubinchyk/79bc8eb1bcd861078027c7dfa999058c to your computer and use it in GitHub Desktop.
Angular1: Send POST request with regular 'post'
var req = {
method: 'POST',
url: 'http://',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
data: {
info: info
}
}
$http(req).then(function(ev){
console.log('Success');
}, function(error){
alert('Not success!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment