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:

Here is the code:

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

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?
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".
894359Author Commented:
Yes, I understand that but is that legal to do?
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.
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.
894359Author Commented:
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.