← Back to team overview

dhis2-devs team mailing list archive

Problem with cross domain when try to get data in Javascript


Dear devs,
I'm writing a script to retry data in Javascript.

<script src="http://code.jquery.com/jquery-1.11.3.min.js";></script>

var username = "admin";
var password = "district";

function base_64_auth(user,password) {
      var tok = user + ':' + password;
      var hash = btoa(tok);
      return "Basic " + hash;

 var auth = base_64_auth('admin','district');

    type: "GET",
    url: "http://lovad.dyndns.org:8080/dhis/api/analytics.json";,
     beforeSend : function(req) {
contentType: ('application/x-www-form-urlencoded; charset=UTF-8'),
//data: myData,
    crossDomain: true,
    dataType: 'json',
    async: true,
    success: function (){
    alert('Thanks for your comment!');


But then I've received this return error. I may because of cross domain
Notes: I've added my WAN IP address into settings -> access

index.html:1 XMLHttpRequest cannot load
Response for preflight is invalid (redirect)

Is it possible to retry data by Javascript with basic auth?

Thank you very much and best regards,

THAI Chuong
YM/Skype : thaichuong159
Phone: (+84) 918776134