erdomester
erdomester

Reputation: 11829

Strange ajax issue with IE

I've come across an IE issue I can't find an explanation to. I have this code that fires an alert in Chrome and Firefox but it doesn't in IE. I don't even call GetDictBySubtitle().

<?php
header('Content-type: text/html; charset=UTF-8');
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Something</title>

    <link rel="stylesheet" href="../css/bootstrap.css" type="text/css">
    <link href="../css/dashboard.css" rel="stylesheet"/>

    <script>

    function GetDictBySubtitle() {

        var userid = "000000000027";
        var subid = "6317450";
        postData = {"userid":userid, "subtitleid":subid};               
            $.ajax({
                url: "/cgi-bin/get_movie_dictionary.py",
                type: "post",
                datatype:"json",
                async : true,
                data: {postData},
                success: function(response){
                    alert(response);
                } 
            });

    }

     function GetAccountData() {

        var userid = "000000000027";
        alert(userid);

    }

</script>

</head>
<body>

<script>
    window.onload = function() {
        GetAccountData();
    }
</script>

AN ALERT SHOULD BE DISPLAYED

</body>

    <script src="../js/jquery.js"></script>
    <script src="../js/jquery-ui.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../js/light-bootstrap-dashboard.js"></script>


</html>

I also added cache: false to the request, but it's not a caching issue, because I deleted everything from IE, restarted it, and the alert is still lurking somewhere in the dark.

Note: While debugging the page in IE, I get GetAccountData() is undefined error in the window.onload block.

I'm using IE 10, Chrome 50, Firefox 45.

It's so great that I can always count on Microsoft if I have time to kill.

Upvotes: 0

Views: 32

Answers (1)

Change

data: {postData},

to

data: postData,

And test again.

Why?

Because postData is an object.

{postData} is incorrect. In this case Internet Explorer has detected the error and blocks the execution.

Upvotes: 1

Related Questions