Basically, assuming that at some point you are going to post the result on a real web server, the first corresponds to the target environment, and the second does not. Browsers process local files and files served from web servers (even localhost web servers) differently, although it is very similar. One aspect of this is encoding: when you retrieve a file from a web server, the process of determining what encodes the data is different from opening a local file.
How does this affect interaction with another server, i.e. Ajax requests?
This is one of the main ways in which they are processed in different ways, and even from browser to browser. A page loaded from the file:// URL has a null origin in terms of a policy with the same source code. Some browsers (such as Chrome) completely prohibit sharing Cross-Origin resources for a null source, even if the server you are trying to talk to has a wide-open CORS policy ( * ). Others (e.g. Firefox) allow origin null match the pattern.
In general, for best results, make sure your development environment matches your deployment environment in important ways. This means that you are doing your development using a web server process, not local files. Most IDEs will happily provide you with this process; if not, Apache or Nginx is not difficult to install.
source share