0
所以我試圖做一個網頁,通過客戶端啓動本地應用程序。Cross Domain post Javascript
我能想到的simplist解決方案只是發佈或獲取數據到我想要使用的端口;說端口3000.不幸的是我遇到了一個錯誤:XMLHttpRequest cannot load %3127.0.0.1:3000. Cross origin requests are only supported for HTTP.
我的問題: 有沒有辦法使用XMLHttpRequest()發佈或獲取數據到127.0.0.1:3000?
對格式混亂對不起,我打得四處很長一段時間,我不能讓它正確地縮進d:
function Post_Command(Command_String){
if(typeof(Command_String) != "string"){
console.log(
"Invalid Call:\Post_Command(\n\t"+Command_String+":"+typeof(Command_String)+"\n)"
);
} else {
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
console.log(xmlhttp.responseText);
}
}
xmlhttp.open(
"POST",
"127.0.0.1:3000",
true
);
xmlhttp.send(Command_String);
}
}
這可能是我正在尋找。它也不會是一個接收數據的瀏覽器,它只是一個客戶端應用程序,它可以解析接收到的數據。我也會寫這個。 – Ignoreme