Ajax Call to Service produces Error ==> "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https."

I'm trying to connect to a service outside our firewall but on our servers and I'm getting the following error:

error
Here is the code:

Code
Not sure how I get around this? This is all new to me?

Thanks!
894359Asked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
If the service is outside your firewall - how is http://d53bhbweb001t0w:1001/ going to resolve - there is no tld in your URL?
0
 
Dave BaldwinFixer of ProblemsCommented:
I think it's saying that you need a "protocol scheme" in your URL like:
var url = "http://d53bhbweb001t0w:1001/,,,,,

Open in new window

And that's because it's not a "local file".
1
 
894359Author Commented:
HI,
Yes, I understand that but is that legal to do?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
I think it is required for the AJAX code to know how to connect to a non-local file or program.  If it was 'local', it would normally use the same 'scheme' that was used to load the page it is on.
0
 
Brian DayhoffConnect With a Mentor Senior Full Stack DeveloperCommented:
Ajax requires http protocol. So you need
var url = "http://..."

Open in new window


However this will choke on ssl. The safest way to sent ajax is to use this sort of prefix:

var url = "://..."

Open in new window


Which means "Use the same protocol I originated from.". If the remote host is using SSL, they will upgrade the insecure request automatically. If not, they will just take the http request as is.

The other protocols in the error body are for chrome-specific internal requests, and are not relevant to your issue unless you are writing a browser plugin that does not make external requests to anything other than google.
0
 
894359Author Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.