Angular post parameter passing backend php cannot receive-fan Dingwen many times we need to submit post Data Using ajax. angularjs is similar to jq and has encapsulated post.
However, jQuery post is much simpler and more user-friendly than angularjs post.
There seems to be no difference between the two. The data submitted with $ http from angularjs cannot be obtained through $ _ REQUEST/$ _ POST on the php server.
This is because the post processing of the header is different between the two ...... JQuery serializes myData as a JSON object,Angular does not.
Solution:
Modify the default processing of Angular $ httpProvider (the most perfect solution)
angular.module('MyModule', [], function($httpProvider) { // Use x-www-form-urlencoded Content-Type $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; /** * The workhorse; converts an object to x-www-form-urlencoded serialization. * @param {Object} obj * @return {String} */ var param = function(obj) { var query = '', name, value, fullSubName, subName, subValue, innerObj, i; for(name in obj) { value = obj[name]; if(value instanceof Array) { for(i=0; i