TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Cross Domain AJAX Works with IE All Version + Chrome + Firefox
Balaji Vishwanath
Nov 06
2015
Code
1.5
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<script type=
"text/javascript"
>
function isIE()
{
var myNav = navigator.userAgent.toLowerCase();
return
(myNav.indexOf(
'msie'
) != -1) ? parseInt(myNav.split(
'msie'
)[1]) :
false
;
}
jQuery(window).load(function()
{
if
(isIE() <= 9 && window.XDomainRequest)
{
if
(window.XDomainRequest)
{
var xdr =
new
XDomainRequest();
var query =
"URL"
;
if
(xdr)
{
xdr.onload = function()
{
alert(xdr.responseText);
}
xdr.onerror = function()
{
/* error handling here */
}
xdr.open(
'GET'
, query);
xdr.send();
}
}
}
else
{
jQuery.ajax(
{
type:
"GET"
,
crossDomain:
true
,
url:
"URL"
,
dataType:
"json"
,
success: function(data)
{
alert(
"Success"
);
},
error: function(response, textStatus, errorThrown)
{
alert(
'not OK '
+ response.responseText);
alert(
'not OK '
+ textStatus.responseText);
alert(
'not OK '
+ errorThrown);
}
});
}
});
</script>
Ajax
IE 9
Chrome
Firefox