Answer the question
In order to leave comments, you need to log in
Why ajax request sometimes returns html page?
In an application, the backend is separated from the frontend. The entry point for the front is index.html and the backend is api.php. The front communicates with the backend through ajax requests, but some requests apparently go to index.html, resulting in an html page in the response. Requests are regulated by .htaccess, maybe I didn't configure it correctly:
AddDefaultCharset utf-8
Options -Indexes
RewriteEngine On
RewriteBase /
# if it is ajax request
RewriteCond %{HTTP:X-Requested-With} XMLHttpRequest
RewriteRule . api.php [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html
Answer the question
In order to leave comments, you need to log in
Check the headers being sent, as you look only at them, the point is most likely in this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question