Search code examples
javascriptxmlhttprequest

Http 200 in logs, but page doesn't redirect in appengine


I have a JavaScript client on my App Engine app that listens to a channel and makes a GET request like this when there a message is posted on the client:

<script type="text/javascript" src="/_ah/channel/jsapi"></script>
<script>
    channel = new goog.appengine.Channel('{{ token }}');
    socket = channel.open();
    socket.onmessage = function() {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', '/secondpage');
        xhr.send();
      };
</script>

After the server posts a message on the channel I can see a successful HTTP 200 response in the logs, but the page doesn't actually redirect to the new page. Here's the app log:

enter image description here

Any ideas why this is happening ?


Solution

  • Either insert the received HTML code into the page DOM (insert/replace/append,such as insertAfter, or the straightforward innerHTML=), or, if you are getting a full page,
    a) send "Location: [url]" redirect 302 header on the server side, or
    b) call JavaScript window.location.reload(); to refresh the entire page on the client side (location.reload).
    Thank you for your attention,
    Tom