我对本机Ajax请求调用有一个奇怪的问题.
我正在创建Ajax对象并发送如下请求:
var xmlHttpObj = new XMLHttpRequest();
….
xmlHttpObj.open("GET","http://192.168.16.254:8080/ajax/demoExample.html",true);
xmlHttpObj.send();
当我使用类似http:// localhost:8080 / ajax …的URL访问servlet时,
然后我无法在客户端获得响应.但我可以在服务器端看到响应.
我用同样的方式调用了请求
xmlHttpObj.open("GET","http://localhost:8080/ajax/demoExample.html",true);
我的URL是http://192.168.16.254:8080 / ajax …,然后我也无法在客户端看到响应.
我知道解决问题的最佳方法.
我可以调用请求
xmlHttpObj.open("GET","../ajax/demoExample.html",true);
xmlHttpObj.send();
那么我对localhost或IP地址没有任何问题.
但我仍然认为为什么ajax请求中localhost和IP地址之间的区别.