开发者

Changing localhost to my machine name in the request url in jquery does not work

I have a WCF service that works fine on my local machine, and a client that uses AJAX from jQuery, everything is working fine locally using localhost in the url, I tried to replace localhost with my machine name, and run again locally, but the request does not work and causes error in the response of the calback function in js.

The response does not hold any 开发者_如何学JAVAmeaning information (readystate = 4, error)


It could be that you are violating Same Origin Policy. Have you tried changing the URL in browser to your machine name as well?

On another note, since you can, normally, only do AJAX calls on the same host, you should simply use relative paths over absolute paths, e.g. /foo/bar?key=val instead of http://localhost/foo/bar?key=val.


I'm not perfectly sure, but this seems like a problem in your service. It sounds like your service ist bound to localhost, resp. to the IP 127.0.0.1.

If you want to access it via your LAN IP address, just make sure, the service is bount to it.

Hope that helps.


use IP address of your system instead of mahcine name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜