jQuery Ajax + ie8 + iis results in error
I have the following code that will pull geocode from google:
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({ url: "http://maps.googleapis.com/maps/api/geocode/json",
context: document.body, success:function(response) {
alert("success");}, error: function( jqXHR, textStatus, errorThrown
){alert(textStatus);}, data:"sensor=false&address=L3R4M9",
type:"GET"});
});
});
</script>
</head>
<body>
<button>Send an HTTP GET request to a page and get the result back</button>
</body>
</html>
When I press the button, the code fails with "error". jqXHR has no
responseText, has a status of "0" and both textStatus and errorThrown just
say "error". This code works on ie10, chrome and firefox. This ALSO works
on php hosted servers with ie8 which is VERY odd. I don't have access to
the server, so hopefully this is not a server issue.
Locally, I am able to pull data, so if I have a file called text.txt, I am
able to ajax it in on that server with ie8. I've also tried the following:
putting in header
changing $.ajax to $.get
settting dataType: json and jsonp
Added the following into my settings
xhr: (window.ActiveXObject) ? function() { try { return new
window.ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} } : function() {
return new window.XMLHttpRequest(); },
added this before my ajax call
jQuery.ajaxSetup({ xhr: function() { //return new window.XMLHttpRequest();
try{ if(window.ActiveXObject) return new
window.ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { }
return new window.XMLHttpRequest();
But none of those have successfully worked.
No comments:
Post a Comment