Search code examples
jqueryajaxhtmlcross-domainsame-origin-policy

What is the meaning of 127.0.0.1 in Ajax?


There are 2 servers in the same physical machine. The first server is for Front-end use through port 80, and the second server is for API use through port 81.

There are cross domain issues when I request jQuery Ajax from the first server to the second server. So I changed the configuration from url :192.168.x.x:8080 to url : 127.0.0.1

An error appears as

"net::ERR_CONNECTION_REFUSED"

Unfortunately, I misunderstand the meaning of 127.0.0.1 in ajax.

What does ajax call when the configuration is url : 127.0.0.1 ,

The Server? Or my Client?

Thank you


Solution

  • 127.0.0.1 is the IP address of localhost / the same machine. In fact 127.0.0.2 is the same machine too. Most IPs beginning with 127 refer to self.