cloud
cloud

Reputation: 527

Data in AJAX callback function is undefined in IE8 only

I wrote a page called test.jsp to learn how to get data from a server. The JS code for test.jsp:

I didn't add {async: false} option at first, but it didn't work as well.

<script type="text/javascript">
    $(document).ready(function(){
        $.get(
            "./tabServlet?t=" + new Date(),
            { async: false },
            function(data) {
                alert(data);
            }
        );
    });
</script>

Critical code for a simple servlet:

protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
{
    PrintWriter out = response.getWriter();
    out.print("12345");
    out.close();
}

The problem is that in IE8, alert(data) shows undefined. The same code works fine with Chrome. Can anyone tell me why this is?

Upvotes: 0

Views: 468

Answers (1)

CharlesX
CharlesX

Reputation: 128

I tried this in IE8 and it worked fine. You can debug the code and see what's wrong with your code, first make sure the response "12345" is returned.

Upvotes: 1

Related Questions