如何在不刷新整个页面的情况下更改网站内容? [英] How Do I Change Website Content Without Refreshing The Entire Page?

查看:121
本文介绍了如何在不刷新整个页面的情况下更改网站内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Guys,



所以我是网站世界的新手,我知道Basic HTML和Basic CSS,这是我对编码最了解的。 />
我在网上搜索了答案,但这对我来说都是胡言乱语。



我正在建立一个网站,在我的导航中我有家,新闻,商店,服务器信息和论坛。



我想在主屏幕上进行操作,如果我点击新闻按钮,内容新闻页面将显示在主页上而不刷新整个网站。



我听说过Ajax,JQuery和Javascript以及PHP但我不知道第一个关于他们中的任何一件事。



是否有人能够给我一步一步的指导,说明在哪里放置代码和所需的代码?



这将非常有帮助,我会非常感激!



-Regards,

Michael 。

Hey Guys,

So I am new to the website world, I know Basic HTML and Basic CSS and that is the most I know about coding.
I have searched online for answers but it is all gibberish to me.

I am making a website and in my navi I have Home, News, Shop, Server Info and Forums.

I would like to make it to when i am on the home screen, if I click the news button, the content of the news page will show on the home page without refreshing the entire website.

I have heard about Ajax, JQuery and Javascript as well as PHP but I do not know the first thing about any of them.

Is anyone able to give me a step by step instruction on where to place the code and the code needed?

It would be very helpful and I would be very thankful!

-Regards,
Michael.

推荐答案

这个问题没有了总而言之。即使刷新页面也无法更改网站内容。



内容只能在服务器端更改,但当然可以代表客户端,并且只有服务器端脚本被设计为这样做。



不要误会我的意思:你可以改变页面上的内容客户端通过JavaScript更改DOM。这不被视为改变网站;更改不会超出浏览器。



现在,分步说明。我经常遇到类似的问题,并对它们提出了一些保护措施:如果这样的指示是可能的,人们会开发一些软件,只需在没有你帮助的情况下完成这些步骤。不那么简单。不,没有说明可以帮助你。您只需要了解Web的工作原理;没有其他办法。拿这个Ajax:

https://en.wikipedia.org/wiki/Ajax_(programming ) [ ^ ],
http://api.jquery.com/jquery.ajax [ ^ ]。



这几乎是所有关于Ajax。 (当然,基于它有不同的框架,但基本上就是这样。)在你理解之前,它似乎很神秘:没有服务器端技术,它什么都不做。这都是关于获取HTTP请求并将其处理成某些HTTP响应,这可能涉及一些副作用。这种副作用,没有别的,可以改变副作用。例如,您可以将一些文件添加到为您的站点设置的根目录下的文件系统部分,或者修改一些文件。这种修改的部分情况是某些数据库中的更改,该数据库可以位于单独的上。只有当你进行了持续修改时,才真正改变网站的内容。



所以,这是另一个说没有什么理由的理由告诉您:首先,您需要学习一些服务器端技术并选择一个或一些选项来做出决定。否则,没有什么可谈的。因此,一些分步说明是可能的,它们被简化为两个:1)学习Web如何工作,2)学习一些服务器端技术。



如果您在这方面遇到一些问题 - 欢迎回答您的问题。



-SA
The question makes no sense at all. You cannot change Web site content even with refreshing the page.

The content can only be changed on the server side, but of course it can be done on the behalf of the client, and only if the server-side script is designed to do so.

Don't get me wrong: you can change the content of the page on the client side by changing DOM via JavaScript. This is not considered as "changing the site"; the change will not go outside of the browser.

Now, "step by step instructions". I often had similar questions and developed some protection against them: if such instructions were possible, people would develop some software which would simply do these steps without your help. Isn't that simple. No, no instruction can help you. You just need to learn how Web works; there is no other way. Take this Ajax:
https://en.wikipedia.org/wiki/Ajax_(programming)[^],
http://api.jquery.com/jquery.ajax[^].

That's pretty much all about Ajax. (Of course, there are different frameworks based on it, but essentially that's it.) It will seems mysterious to you until you understand: it does nothing at all without some server-side technology. It's all about getting HTTP request and processing it into some HTTP response, which can involve some side effect. This side effect, and nothing else, can change the side content. For example, you can add some files to the part of file system under the root directory set up for your site, or modify some files. A partial case of such modification would be the change in some database, which can be on a separate tier. Only if you do such persistent modifications, you really change the site's content.

So, here is another reason to say that there is nothing to instruct you about: first, you need to learn some server-side technology and choose one, or some options for a decision. Otherwise, there is nothing to talk about. So, is some "step by step instructions" are possible, they are reduced to the two: 1) learn how Web works, 2) learn some server-side technology.

If you face some problems on this way — welcome back to your questions.

—SA


是的,你可以。 AJAX 会为你做这件事。



根据 W3C [ ^ ],

什么是AJAX?

AJAX =异步JavaScript和XML。

< b> AJAX 是一种用于创建快速动态网页的技术。

AJAX 允许通过交换少量数据异步更新web 页面与服务器幕后。这意味着可以更新网页的各个部分,而无需重新加载整个页面



请参阅此处的一些基本示例,

https://css-tricks.com/dynamic-page-replacing-content/ [ ^ ]

http:// crunchify。 com / how-to-refresh-div-content-without-reloading-page-using-jquery-and-ajax / [ ^ ]



和教程,

AJAX教程 [ ^ ]

jQuery.ajax() [ ^ ]



:)



-KR
Yes, you can. AJAX would do this for you.

According to W3C[^],
What is AJAX?
AJAX = Asynchronous JavaScript and XML.
AJAX is a technique for creating fast and dynamic web pages.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

See some basic examples here,
https://css-tricks.com/dynamic-page-replacing-content/[^]
http://crunchify.com/how-to-refresh-div-content-without-reloading-page-using-jquery-and-ajax/[^]

And tutorials,
AJAX tutorial[^]
jQuery.ajax()[^]

:)

-KR


这篇关于如何在不刷新整个页面的情况下更改网站内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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