post
Why is HttpRequest sending the OPTIONS verb instead of POST?
The OPTIONS verb is a preflight request sent by some browsers to check the validity of cross origin requests. It pretty much checks with the server that the Origin(requester) is allowed to make the request for a specified resource. Also, depending on which headers are sent back by the server it lets the browser know … Read more
Nodejs POST request multipart/form-data
After some more research, I decided to use the restler module. It makes the multipart upload really easy. fs.stat(“image.jpg”, function(err, stats) { restler.post(“http://posttestserver.com/post.php”, { multipart: true, data: { “folder_id”: “0”, “filename”: restler.file(“image.jpg”, null, stats.size, null, “image/jpg”) } }).on(“complete”, function(data) { console.log(data); }); });
What’s the difference between : 1. (ajaxStart and ajaxSend) and 2. (ajaxStop and ajaxComplete)?
.ajaxStart() and .ajaxStop() are for all requests together, ajaxStart fires when the first simultaneous request starts, ajaxStop fires then the last of that simultaneous batch finishes. So say you’re making 3 requests all at once, ajaxStart() fires when the first starts, ajaxStop() fires when the last one (they don’t necessarily finish in order) comes back. … Read more
http Post request with Typescript
Update 2020: Note that as of now, the global fetch is available on all modern browsers and covers 95% of all web users. If you need support for IE, read the original answer. MDN Doc | TypeScript Definition Where the function is available in the window or global contexts, looks like: fetch(input: RequestInfo, init?: RequestInit): … Read more
Angularjs how to upload multipart form data and a file?
First of all You don’t need any special changes in the structure. I mean: html input tags. <input accept=”image/*” name=”file” ng-value=”fileToUpload” value=”{{fileToUpload}}” file-model=”fileToUpload” set-file-data=”fileToUpload = value;” type=”file” id=”my_file” /> 1.2 create own directive, .directive(“fileModel”,function() { return { restrict: ‘EA’, scope: { setFileData: “&” }, link: function(scope, ele, attrs) { ele.on(‘change’, function() { scope.$apply(function() { var … Read more
Is Content-Type mandatory in HTTP post request?
No, it’s not mandatory. Per the HTTP 1.1 specification: Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its … Read more