[英]Help changing content on the page using both php and javascript
So I am trying to have a dynamic tabs kind of thing using both php and javascript. 因此,我尝试使用php和javascript来制作动态标签。 To make it much easier to understand, remember the two choices on facebook (Recent news and most recent) or something like that, when you click on one of them it just changes the content that you see in the middle without updating the page.
为了使其更容易理解,请记住在facebook上的两个选择(最近新闻和最新选择)或类似内容,当您单击其中的一个时,它只是更改了您在中间看到的内容,而没有更新页面。 i know how to delete the content in a div for example, but after deleting the content in the div (innerHTML = "") I want to populate it with the option chosen from the database.
例如,我知道如何删除div中的内容,但是在div中删除内容后(innerHTML =“”),我想使用从数据库中选择的选项填充它。
So let's say I have an option (all) and an option (only this) The default is all so when I run the page, I will just get all. 假设我有一个选项(全部)和一个选项(仅此选项)。默认值是全部,所以当我运行页面时,我将得到全部。 However, if I click on only this, it will clear the div "my header" and will replace the content with the latest content from the database (database) and display it.
但是,如果仅单击此按钮,它将清除div“我的标头”,并将内容替换为数据库(数据库)中的最新内容并显示它。
For that I need both php and javascript, is there a sample or an easy way to do this before i start digging around. 为此,我需要同时使用php和javascript,在开始研究之前,是否有示例或简单的方法可以做到这一点。
((Sorry if is not clear but the facebook example should be clear enough)) ((抱歉,如果不清楚,但是facebook示例应该足够清楚))
Whatyou are looking for a is AJAX/PHP approach. 您正在寻找的是AJAX / PHP方法。
This is basically the way it is done. 这基本上是完成的方式。
Check out the different JavaScript frameworks. 查看不同的JavaScript框架。 They all come with nice AJAX support:
它们都具有很好的AJAX支持:
And of course, SO is also a nice place to look at: https://stackoverflow.com/questions/tagged/ajax+php 当然,SO也是一个不错的地方: https : //stackoverflow.com/questions/tagged/ajax+php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.