Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71088

Xhr works in cordova app but not in ionic application

$
0
0

@ankant wrote:

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

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71088

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>