Dworza Dworza - 3 months ago 14
HTML Question

Change HTML code without refreshing the page

Is there any possibility

how to change HTML
(.jsp) page
without refreshing
it?

Usecase is that user writes something to textarea then hits some button and I need then to add some object ie picture to previously defined place in my page ~~~> I need to change HTML code without refreshing the page (without the loss of the text in the textbox). I really need to change the HTML code, so pls don't advice any solution without changing the HTML code.

I'm not very into frontend technologies, so I don't know if it's even possible, so excuse me pls, if this is a stupid question.

I can use only frontend technologies.

Answer

Using jQuery (a JavaScript library) you can utilize the load() function to load the contents of another HTML file on your server and place it anywhere you want on the current page without refreshing (so you can even replace the current HTML if you like).

jQuery:
http://jquery.com/

jQuery load():
http://api.jquery.com/load/


Alternative Suggestion:
However, I know you say you can't refresh the page, but, if the only reason is because you need to keep the text in the textbox, you could use a form to POST that text to another .jsp page (or even the same .jsp page, depending on how you go about it) where it will be available to you to use at your own discretion (to put it in another textbox, for example).