Reputation: 8782
I'm trying to GET a response from a web server that I run on Localhost(127.0.0.1
), Exactly form this URL: http://127.0.0.1:3125/ping
.
The request is invoked by an html file that look like this, loaded in an Electron app:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$.get( "127.0.0.1:3215/ping", function( data ) {
console.log( data );
});
}
);
</script>
</body>
</html>
However using the DevTools(console) while in the app, I can see that the response is always GET http://localhost:3215/ping 404 (NOT FOUND)
and if I try to request a page, not in localhost(like http:google.com
), the request is always successful.
And even if a try to start the request(on localhost) from my browser console, it is always successful.
I can't understand why electron behaves like this.
Upvotes: 2
Views: 4089
Reputation: 160
You have not specified the protocol you want to use for the request, http:// or https://.
$.get( "http://127.0.0.1:3215/ping", function( data ) {
console.log( data );
});
Upvotes: 2