JQuery calling WebAPI

JQuery calling WebAPI

I have a script that is calling a WebAPI. If I host the web page and the API on the same server it works fine, however, when I move the API to our app server and the web page to the web app server, I get the following error messages when calling the URL of the API:

SEC7120: Origin http://localhost:2020 not found in Access-Control-Allow-Origin header.
SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.

I can access the service directly in the browser from both servers. My script looks like this for the URL call;

  1.   $.ajax({
                    url: "http://servername:2020/api/cars/GetAllCars/",
                     type: "GET",
                     crossOrigin: true,
                     dataType: "xml",
                     success: function (data) {
                         xmlParser(data);
                     },

I'm calling other API's on other servers the same way, is there something wrong with the script or should I change the API code? I