Accessing Client#39;s #39;localhost#39; from JavaScript Online(從 JavaScript Online 訪問客戶端的“本地主機(jī))
本文介紹了從 JavaScript Online 訪問客戶端的“本地主機(jī)"的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
這就是我想要做的.
我制作了一些包含 JavaScript 代碼的 .html 頁面,并將它們托管在 Yahoo 服務(wù)器上.
現(xiàn)在,當(dāng)具有特定瀏覽器的客戶端查看這些網(wǎng)頁時(shí),JavaScript 代碼使用 XMLHTTPRequest
在 h1ttp://localhost:8080/myservlet/servlet1 建立連接以讀取一些數(shù)據(jù).
我知道,我想連接到客戶端計(jì)算機(jī)上運(yùn)行的 Web 服務(wù)器,如果客戶端有一個(gè),即我在我的 xmlHTTPRequest 中使用 localhost.
但是,即使客戶端在端口 8080 上運(yùn)行 Web 服務(wù)器,這也不起作用.在客戶端的計(jì)算機(jī)上,我可以訪問 http://localhost:8080/mysevlet/servlet1
并且 servlet 是運(yùn)行良好,但通過 Yahoo 服務(wù)器上托管的 .html
頁面無法正常工作.
我在這里做錯(cuò)了什么?
解決方案
跨站腳本
this is what I am trying to do.
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.
You cannot access what is not on your domain, unless it is a Web Service returning XML or JSONP
這篇關(guān)于從 JavaScript Online 訪問客戶端的“本地主機(jī)"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!