Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save s9tpepper/3328010 to your computer and use it in GitHub Desktop.

Select an option

Save s9tpepper/3328010 to your computer and use it in GitHub Desktop.

Revisions

  1. s9tpepper created this gist Aug 11, 2012.
    9 changes: 9 additions & 0 deletions modifyAngularDefaultRequestContentTypeHeader.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    // The .config() part is the relevant part, 'SomeModule' is arbitrary name,
    // but this config() call goes on your main ng-app="YourAppModule"
    // The PHP $_POST expects data w/ a form content type, not a JSON payload
    angular.module("YourAppModule", ["SomeModule"]).config(function($httpProvider) {
    $httpProvider.defaults.headers.put['Content-Type'] =
    'application/x-www-form-urlencoded';
    $httpProvider.defaults.headers.post['Content-Type'] =
    'application/x-www-form-urlencoded';
    });