Reputation: 527
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
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