I am trying to call open on xmlhttprequest in my javascript code but I am getting an exception "Access is Denied".
Here is my code:
<script type="text/javascript">
function doFunction() {
alert("hi");
xhr = new XMLHttpRequest();
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xhr = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "https://localhost:1234/test/pi/testing/operation";
try{
xhr.open("POST", url, true);
} catch(err) {
alert(err.message);
}
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
alert(xhr.responseText);
}
}
var testText = document.getElementById("test").value;
var jsonObject = { Status: "1", ErrorList: "", test: testText, Price: "" };
var data = JSON.stringify(jsonObject);
xhr.send(data);
}
</script>
The page itself is running on my IIS at localhost:8080 and I am trying to invoke my wcf service on localhost:1234. I added https://localhost to my trusted sites but still not working why is that?
Thank you ;)
Added http://localhost to my trusted sites and started working. The question and this answer applies for IE 10