改变使用AJAX网页的皮肤皮肤、网页、AJAX

2023-09-10 20:10:01 作者:乖巧撩人

我有一个cookie被设置为存储用户的主题preference,等等,但我以前从未使用AJAX,所以我可以使用一些帮助。

I've got a cookie set up to store the user's theme preference, etc., but I've never used AJAX before, so I could use a little help.

我发现这个简单的小AJAX教程,这足以让我开始,但我不知道我是否会更好,再有服务器发送pretty的太多整个网页全部结束,用更新的主题,或者 - 如果它是可能的 - 具有服务器发送一个脚本这将修改页面,保持内容不变,但改变了DIV等性能,从而实现了新的面貌。

I found this simple little AJAX tutorial, which is enough to get me started, but I'm not sure if I'd be better off having the server send pretty much the entire web page all over again, with the updated theme, or -- if it is possible -- having the server send a script that would modify the page, keeping the content intact, but changing the div, etc. properties in order to achieve the new look.

思考?评论? 你这样做是错的,白痴?

Thoughts? Comments? "You're doing it wrong, moron"?

在此先感谢!

推荐答案

如果只改变主题意味着改变你的div的类和页面结构的elemtes,你必须这样做只是改变类=属性附加伤害的在HTML elemts参与。 EJ:(!从服务器0%的流量,漂亮的),您可以更改志愿服务岗位,以及彩车,颜色等等等等。这只会在客户端澳鹏没有要求再次服务器的页面

If changing theme means only change the classes of your divs and the elemtes of the structure of your page you must do it simply changing the class="" atribute of the html elemts involved. Ej: You can change postions, and floats, colors etc etc.. This would appen only in client without asking to the server again the page (0% traffic from server, nice!)

但是,如果改变的主题意味着让其他HTML结构和层次complety不同:你不要有再次问到服务器上的页面与其他方式的新的HTML ...

But, if changing theme means to get other html structure and hierarchy complety different: You dont have other way that ask to the server the page again with the new html...

结论:考虑所有这些事情,如果你能得到其他的主题只起了变化的CSS,你可以/必须使用jQuery改变CSS属性。但是,如果没有,你需要从服务器加载新的HTML ...

Conclusion: Think about all those things, if you can get other theme only changin css you can/must use jquery to change the css properties. But, if not, you need to load the new html from the server...

我希望这可以帮助您

PD:对不起,我englisgh语法如果不正确,在所有

pd: sorry for my englisgh grammar if its not correct at all!