$ HTTP is the Ajax service provided by angular.
It also involves
$ Httpbackend, $ httpprovider,
$ Q (angular promise ),
$ Cachefactory (angular cache mechanism) and so on
The first time I used the POST request yesterday, I encountered a tragedy when I went to data after the POST request was rejected by ashx.
I flipped through the source code.
The original problem lies in Content-Type.
Angular's default Content-Type is application/JSON, and we usually use application/X-WWW-form-urlencoded (this is also true for jquery)
VaR Content_type_application_json = {'content-type': 'application/JSON; charset = UTF-8' }; Headers: {common :{ 'Accept': 'application/JSON, text/plain ,*/*' }, Post: shallowcopy (content_type_application_json ), // Shallowcopy is a shallowcopy. Put: shallowcopy (content_type_application_json), Patch: shallowcopy (content_type_application_json )}, // Transform outgoing request data Transformrequest :[ Function (D ){ Return Isobject (d )&&! Isfile (d )&&! Isblob (d )? Tojson (d): D; // data will be processed as JSON}],
In the case of. ashx, if we call content. request ["key"], we cannot obtain data.
We can solve this problem in the original way.
Streamreader reader =NewStreamreader (context. Request. inputstream, encoding. utf8 );StringJSON = reader. readtoend (); // This is data, which is a JSON array.
To be continued...