First a couple of comments:
1. goog.dom.getElement() expects a string, so give it one:
goog.dom.getElement('loginPost'). You're ommiting quotes in most of
your calls.
2. Instead of building postData, use
goog.dom.forms.getFormDataString('loginPost') to get the post
variables.
The issue you're running in to is due to your design. You're replacing
the form with the event handler attached so the event handler will no
longer exist. Using innerHTML will not execute js calls in your
response.
In my opinion as a best practice, an AJAX response should carry only
data, not logic. Your callback will perform any logic/processing that
needs to occur. So if you return HTML, rather return a stub (returning
and replacing just the input fields with their validation messages
will not affect the event handler). Have you considered returning JSON
instead of HTML stubs. For example:
{'code':0, 'errors':[{'loginEmailAddress':'Invalid email address'},
{'loginPassword':'Invalid email address'}]}
Code 0 would indicate an error (1 could indicate success), and you
have your field names and validation messages which you can easily
display.
In the above code, did you try calling myproject.login() just before
xhr.dispose()?
> make a Async POST request tohttp://127.0.0.1:8080/myproject/login
> url.
>
> The response from this request will be displayed in a div block whose
> id is set to "displayContent". The following code snippet will do
> that
>
> goog.dom.getElement('displayContent').innerHTML = response;
>
> On the server-side the response from a POST request tohttp://127.0.0.1:8080/myproject/login could be of two types: