connecting one instance to another instance from Java Script to Angular

I have two applications:
1. basic web.xml based servlet application running on instance X web server 1 – http://localhost:8080/Route.Js

  1. Angular based application also running on the same instance X web server 2 – http://localhost:4200/Primary

So from the application 1, Js file we need decision-making process to send/redirect to angular application. I have tried the following options.


var xhr = new XMLHttpRequest();"GET", "http://localhost:4200/Primary", true);
 xhr.withCredentials = true;

Option 2:

            url : "http://localhost:4200/Primary",
            type : "POST",
            cache : false,
            async : false,
            success : function(data, textStatus, jqXHR)


            error : function(jqXHR, textStatus, errorThrown)


Option2 throws following error:
XMLHttpRequest: Network Error 0x80070005, Access is denied.

I tried lot on online but now sure how to solve this issue?
Thanks in advance

Source: AngularJS