animalnots
animalnots

Reputation: 29

jQuery get data returns undefined in IE

There is a problem in IE 9 returning undefined instead of data, when making an ajax request. It works on Firefox, Chrome, Opera. I tried to set some headers in get.php. But it didn't help.

My code is below:

<head>
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script type="text/javascript">
       $(document).ready(function(){
           $.ajax({
               type : "GET",
                url : "get.php",
               data : "id=1234&lang=en",
           dataType : 'html', 
            success : function( msg ) {
                         alert( "Data Saved: " + msg);
                     }
           });
       });
    </script>
</head>

Upvotes: 2

Views: 1652

Answers (1)

Randy
Randy

Reputation: 938

Returning the MIMEType of application/json; charset=utf8 caused this same behavior for me in IE8. Changing it to application/json; made IE8 magically start functioning. Check what your server is returning for a MIMEType and see if fiddling with that is causing an issue.

Edit: Actually what was causing the real problem is that it should be charset=utf-8 and not as shown above without the hyphen.

Upvotes: 2

Related Questions