Accessing Client#39;s #39;localhost#39; from JavaScript Online(从 JavaScript Online 访问客户端的“本地主机)
问题描述
这就是我想要做的.
我制作了一些包含 JavaScript 代码的 .html 页面,并将它们托管在 Yahoo 服务器上.
现在,当具有特定浏览器的客户端查看这些网页时,JavaScript 代码使用
XMLHTTPRequest
在 h1ttp://localhost:8080/myservlet/servlet1 建立连接以读取一些数据.我知道,我想连接到客户端计算机上运行的 Web 服务器,如果客户端有一个,即我在我的 xmlHTTPRequest 中使用 localhost.
但是,即使客户端在端口 8080 上运行 Web 服务器,这也不起作用.在客户端的计算机上,我可以访问 http://localhost:8080/mysevlet/servlet1
并且 servlet 是运行良好,但通过 Yahoo 服务器上托管的 .html
页面无法正常工作.
我在这里做错了什么?
跨站脚本
一个>
您无法访问不在您域中的内容,除非它是返回 XML 或 JSONP 的 Web 服务
this is what I am trying to do.
I have made a few .html pages with JavaScript code in it and hosted them on a Yahoo server.
Now when a client with a certain browser views these web pages, the JavaScript code uses
XMLHTTPRequest
to make a connection at h1ttp://localhost:8080/myservlet/servlet1 to read some data.I know, I want to connect to the web server running on the client's computer if the client has one i.e. I am using localhost in my xmlHTTPRequest.
But this is not working even when a client has a web server running on port 8080. On the client's computer I can access http://localhost:8080/mysevlet/servlet1
and the servlet is running fine, but through the .html
page hosted on Yahoo server it does not work.
Anything that I am doing wrong here?
Cross-site Scripting
You cannot access what is not on your domain, unless it is a Web Service returning XML or JSONP
这篇关于从 JavaScript Online 访问客户端的“本地主机"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 JavaScript Online 访问客户端的“本地主机"
- 失败的 Canvas 360 jquery 插件 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01