In my asp.net mvc website I am making an ajax call to my server when the user pastes something in a certain textbox. This call used to work in IE 8, but now it stopped working in IE 11, giving me an access denied exception in my jQuery 1.7.1 at h.open(c.type,c.url,c.async)
.
Long research hinted me that it might be related to a CORS issue, but... every call is on the same domain.
<input type="text" id="Pasteexcelhere" name="Pasteexcelhere" />
<script type='text/javascript' >
$(function () {
onp();
});
function onp() {
obj = document.getElementById('Pasteexcelhere');
$('#Pasteexcelhere').on('paste', function (e) {
x = obj.value;
$.ajax({
type: "POST",
url: "<%= Url.Action("PasteFromExcel", "RequestData" ) %>",
data: "{'data': '" + x + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
success: function (da) {
alert("success");
},
error: function (d) {
alert(d.statusText); // access denied
}
});
});
</script>
When trying to make the same call directly, let's say via a simple link:
<a id="mylink" href="#" onclick="blubb();return false;">Pasted</a>
<script type='text/javascript' >
function blubb() {
obj = document.getElementById('Pasteexcelhere');
x = obj.value;
$.ajax({
type: "POST",
url: "<%= Url.Action("PasteFromExcel", "RequestData" ) %>",
data: "{'data': '" + x + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
traditional: true,
success: function (da) {
var propertyGrid = $('#RequestedTickers').data('tGrid');
propertyGrid.rebind({});
},
error: function (d) {
alert(d.statusText);
}
});
};
</script>
It works just as expected... (no access denied)
Does anybody have an idea how to get this to run?
Thanks!