0

So i'm trying to make a webpage, that launches local applications through a client.

The simplist solution I can think of is just posting or getting data to the port I want to use; say port 3000. Unfortuantely I've run into an error: XMLHttpRequest cannot load %3127.0.0.1:3000. Cross origin requests are only supported for HTTP.

My Question: Is there a way to post or get data to 127.0.0.1:3000 using XMLHttpRequest()?

sorry about the formatting mess, I played around with it for a long time and I couldn't get it to indent correctly 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); } } 

1 Answer 1

2

Yes, with provisos. Your first problem is that you have to use HTTP or HTTPS. You need a scheme on your URI (or you need to start it with // to maintain the current scheme, which is unwise if you are hitting a specific port).

"127.0.0.1:3000" --> "http://127.0.0.1:3000" 

The server running on port 3000 needs to give permission to the site using CORS. The user must also be equipped with a browser that supports CORS.

Sign up to request clarification or add additional context in comments.

1 Comment

That may be what i'm looking for. It also won't be a browser that's recieveing the data, it's just a client appliaction that will parse what it recieves. I'll be writing that as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.