troubleshooting Question

Simple ajax with cross domain error

Avatar of Steve Tinsley
Steve TinsleyFlag for United Kingdom of Great Britain and Northern Ireland asked on
5 Comments1 Solution108 ViewsLast Modified:
I want to be able to fire a simple HTML request using ajax.
I don't have access to change the server I am requesting, but all it does is fire back OK as plain text if all is ok.

Here is my super simple code:

<!DOCTYPE html>
<script src=""></script>




         url: "",
         success: function(data)

            if (data == "ok") {
            } else {
               alert("not ok :( - " + data);
         error: function(jqXHR, textStatus, errorThrown)
            console.log("Oops: " + textStatus + errorThrown);

      return false;





<div id="div1"></div>



Open in new window

The issue is that i get an error response:

Access to XMLHttpRequest at '' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
untitled.html:36 Oops: error

When I look at the network tab in Chrome I still get the OK back....

Is there a way to avoid this error??
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros