var base = “example.com ”;
Ext.onReady( function() {
Ext.Ajax.request({
url: base + “dhis-web-commons-security/login.json”,
method: “POST”,
params: { j_username: “my_username”, j_password: “my_password” },
crossDomain: true,
xhrFields : {
‘withCredentials’:true
},
dataType : “jsonp”,
success: setLinks
});
});
function setLinks() {
DHIS.getMap({ url: base, el: “map1”, id: “VWJfOyWwhKm” });
}
Please I am trying to embed the map with the code above in my javascript with an existing map but I am getting this error below:
POST http://example.com/dhis-web-commons-security/login.json HTTP/1.1 401.
Can anyone help me on this error please? I am a beginner
Gassim
(AL-Gassim Sharaf Addin)
19 October 2021 14:18
2
Hey and welcome to the community @software_developer20 !
This clearly seems like an issue with authentication, and could be because of crossDomain issue . Have you read the “How to debug common development errors” guide? Please see if the instructions help solve the issue! How to debug common development errors | DHIS2 Developer Portal
Thanks!
I solved it by modifying the url to this: dhis-web-commons/security/login.action and I removed these parameters: crossDomain, xhrFields and dataType. However I am still getting an error which is telling that DHIS is not defined: Uncaught ReferenceError: DHIS is not defined
Here are my external dependencies: