• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2.1 Ajax based input validation inside innerHTML problem

 
qm westview
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

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:


Plus separate javascript code



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.

It seems to me that when using this innerHTML approach, somehow the javascript connection between the Struts2.1 code inside innerHTML and outside the innerHTML are lost.

I was wondering if there is anyway this innerHTML approach for Strtus 2.1 Ajax based form input validation would work.

Qmwestview

(Thanks David for editing suggestion)


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please repost with your code in code tags and disable HTML; it's difficult to read it as-is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic