简体   繁体   中英

Struts Javascript AJAX onsuccess page update <script> invoke

I have a problem with updating an HTML site after an AJAX request success. In my project I'm using old Struts 1 framework with a coolmenus JS component that produces a menu. After a form submit the server returns a block of JS code within <script> tags (among HTML) and these create a menu on page load each time. Now recently I had to implement a solution that is doing an AJAX request for updating my model on server side. Everything to that point is OK, the model is being updated but the problem starts on swapping received html (using prototypejs):

$$('html')[0].innerHTML = t.responseText;

or

$$('html')[0].innerHTML.update(t.responseText);

It breaks my menu creation(there is no menu after update). I tried to get all 'script' tags from the body and invoke them from evalScripts() function, but it doesn't work at all. I mean the scripts are invoked but it doesn't create the menu.
Any ideas?

I was trying to update the whole page, but I didn't have to. I ended up with extraction of the 'content' part of the page without touching the menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM