XMLHttpRequest to OData WebService wants Credentials

MummigerMummiger Member Posts: 5
edited 2014-12-16 in NAV Three Tier
I'am looking for a method to transfer the Credentials from NAV to the JavaScript AddIn.

The following code is used in the .dll.
namespace ProjTree
{
    public delegate void ProjectNodeEventHandler(string Data);

    [ControlAddInExport("ProjTree")]
    public interface ProjTree
    {
        [ApplicationVisible]
        event ApplicationEventHandler ControlAddInReady;

        [ApplicationVisible]
        event ProjectNodeEventHandler GetDataBack;

        [ApplicationVisible]
        void setProjectTree(string projectItems,string currentProject);                  
    }
}

It works really fine, but when I try to do the XMLHttpRequest in JavaScript, Dynamics NAV wants me to put in the User Credentials.
After entering my username and password the code works, but I want the AddIn to take the Credentials automatically.
        var http_request = new XMLHttpRequest();
	var url = "url$format=json";
	http_request.open("GET",url,false);
	http_request.send();
	xmlDocImage = http_request.responseText;
Sign In or Register to comment.