Xhr works in cordova app but not in ionic application

I am trying to send formData using xmlHttpRequest. In a cordova based application, I am able to succesfully establish connection and send data. But the same xhr fails to establish connection when used in ionic application.
Why is it so?
Here is my basic xhr code without any data:

var xhr = new XMLHttpRequest();
xhr.open('POST', '/fdchandler/');
xhr.onload = function() {
  if (xhr.status != 200) { 
	alert(`Error ${xhr.status}: ${xhr.statusText}`); 
  } else { // show the result
	alert(`Done, got ${xhr.response.length} bytes`);
  }
};

xhr.onerror = function(e) {
 alert(JSON.stringify(e));
};
xhr.send();

/fdchandler/ points to the server url. I have configured it through proxy in my ionic.config.json file