This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I run into a problem when trying to run Struts 2.1 Ajax based form input and validation code inside innerHTML
I managed to get the validation working on the server but the Json based Ajax return simply does not go into the form code inside innerHTML. The browser treat the Ajax return as having no relationship with the request issuer. Coding steps are listed below:
This is the original Struts 2.1 based form and input validation code (the client/server validation logic runs fine when not using innerHTML approach):
The same code turned into the following when coming from the server:
I simply merged the above code into multiple line of strings and assigned to a dedicated div’s innerHTML:
I found the http request sent to the server, after the form submit was hit, did not include struts.enableJSONValidation=true. So I inserted the following code into innerHTML:
Then the reply from the server became truly Json basd:
But the problem is that the browser, both Firefox and IE, does not insert the above reply into the form, but treat it as totally irrelevant to the Struts 2.1 code inside the innerHTML and prompt the viewer to save/open it.
I was wondering if there is anyway this innerHTML approach for Strtus 2.1 Ajax based form input validation would work.