nginX
by default does not set CORS
headers for requests with error status codes like 401. There are 2 options here to add CORS
headers:1- If your nginX version is new you have the option of
always
to add to add_header:add_header 'Access-Control-Allow-Origin' $http_origin always;
2- If you got error of
invalid number of arguments in "add_header" directive
, then use more_set_headers
:more_set_headers -s '401 400 403 404 500' 'Access-Control-Allow-Origin: $http_origin';
NOTE:
when this error happens then in $.ajax
or any similar method you wont have access to status codes. So be extremely catious!!!#nginX #web_server #CORS #more_set_headers #add_header #ajax
How to upload a text content as a file in
We have created a binary data from the text which is in the format of
The
#javascript #jQuery #ajax #FormData #Blob #upload
$.Ajax()
?FormData
class is used to create a multipart/form-data
inside of JS code. A sample code speaks thousand words:var formData = new FormData();
var blob = new Blob([YOUR_CONTENT_HERE], { type: "text/html"});
formData.append("file", blob);
We have created a binary data from the text which is in the format of
text/html
, then I have appended the data as an input file with the name of file
(which will be captured on server-side).The
Ajax
part is utterly simple:$.ajax({
type: 'POST',
url: 'https://www.example.com/storage',
data: formData,
processData: false,
contentType: false
}).done(function(data) {});
NOTE:
DO NOT OMIT processData
, contentType
parameters.#javascript #jQuery #ajax #FormData #Blob #upload
https://stackoverflow.com/questions/1964839/how-can-i-create-a-please-wait-loading-animation-using-jquery
#jquery #ajax #loading
#jquery #ajax #loading
Stack Overflow
How can I create a "Please Wait, Loading..." animation using jQuery?
I would like to place a "please wait, loading" spinning circle animation on my site. How should I accomplish this using jQuery?