更改HTML代码而不刷新页面 [英] Change HTML code without refreshing the page

查看:95
本文介绍了更改HTML代码而不刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to change HTML(.jsp)页面without refreshing有可能吗?

Is there any possibility how to change HTML (.jsp) page without refreshing it?

用例是用户在textarea中写了一些东西,然后点击了某个按钮,然后我需要向页面中以前定义的位置添加一些对象(例如图片)~~~>我需要更改HTML代码而不刷新页面(不丢失内容)文本框中的文本).我确实需要更改HTML代码,因此请不要在不更改HTML代码的情况下提出任何解决方案.

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.

推荐答案

使用jQuery(JavaScript库),您可以利用load()函数将服务器上另一个HTML文件的内容加载并将其放置在您的任何位置想要在当前页面上显示而不刷新(因此您甚至可以根据需要替换当前的HTML).

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/

替代建议:
但是,我知道您说您不能但是刷新页面,如果唯一的原因是因为您需要将文本保留在文本框中,则可以使用表格来POST该文本转到另一个.jsp页面(甚至取决于您的操作方式,甚至是相同的.jsp页面),您可以自行决定使用该页面(例如,将其放置在另一个文本框中).

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).

这篇关于更改HTML代码而不刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆