Problem Description:
A few days ago called the colleague's JS interface file, in his own HTML test page OK, on my side of the call when the problem occurs.
During the debug process, it is not possible to move the test HTML to another location, and it is OK to place it in the same hierarchical path as the original HTML test page.
Resolution process:
Very doubt Ah, with F12 debugging, in the invocation of JS, found that the Xmlhttp.status return status is 404, rely on, the original is not found file.
Look carefully, in JS see the following code: "var requesturl =". /servlet/ajaxservlet.jsp ";" The pit exploded,
Fuzzy remember that the reference path parsing in JS is dependent on the file path that references it, so it is changed to an absolute path:
"var requesturl ="/website project name/Intermediate folder/servlet/ajaxservlet.jsp ";". And then it's OK.
Knowledge Point: The relative path in CSS is based on the path of the CSS file, while the path in JS is based on the location of the file where this JS is imported.
Extended:
Relative path reference in CSS, JS: http://www.cnblogs.com/xuxiace/archive/2012/03/06/2381874.html
Summary of relative and absolute paths in the Java Web: http://www.cnblogs.com/jichunhu/archive/2013/01/31/2887042.html
JS relative path correlation (for example: JS path depends on the path of the input JS file)