将简单的列表服务器边/差存储到localstorage [英] Store a simple list server sided / difference to localstorage

查看:130
本文介绍了将简单的列表服务器边/差存储到localstorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何保存一个简单的列表(< ul>< li>< / li>< / ul> )服务器端。我从来没有做过这样的事情。我做的是一个localstorage。
Localstorage很容易,因为你可以添加localStorage到你想要的:

I'd like to know how it is possible to save a simple list (<ul><li></li></ul>) server sided. I never did something like that. What I did is a localstorage. Localstorage is pretty easy tho, as you can just add localStorage to what you want:

$('.myObject').css('color', localStorage.mySavedColor);

并在函数中调用它:

function saveColor() {
  localStorage.mySavedColor = true;
}

那么,服务器端存储是否一样?我想这有点复杂吧?
确切地说,我试着在这个codepen 上保存列表(使用javascript从用户输入创建) / a>服务器端。

So, is server sided storage like the same? I guess it's a bit more complicated right? Precisely I try to save the list (created with javascript from a user input) on this codepen server sided.

<div id="content">
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul>
  </section>
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul>  
  </section>
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul>
  </section>
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul>
  </section>
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul>  
  </section>
  <section class="tabcontent">
    <ul class="plannerlist">
    </ul> 
  </section>
</div>

javascript在特定< ul>

The javascript creates list items in specific <ul>'s, which I wanna save server sided.

推荐答案

Javascript是一个在客户端浏览器中运行的程序。

Javascript is a program that runs in a client browser. If you want to save something server-side, you have to get a server and implement such feature.

您的应用程式似乎会有多个使用者。

It appears that your app will have more than one user.

这意味着:


  • 有某种授权。请注意,大多数用户通常会通过电子邮件讨厌注册和确认帐户。

  • You have to distinguish one user from another probably with some sort of authorization. Keep in mind that most users tend to hate registration and confirming accounts by email.

更好的主意是保存计划程序事件的文本,而不是包含文本的HTML标记。 HTML标签向用户传递一些有用的信息,并打开许多漏洞(考虑保存非转义标签而不是文本)。

A better idea would be to save the text of Planner Events, rather than HTML tags with text. HTML tags carry little useful information to the user and open many vulnerabilities (think of saving an unescaped tag instead of text).

你正在寻找的是服务器端脚本,这与客户端脚本有很大的不同。请查看 PHP的W3S教程以开始使用。

What you are looking for is server-side scripting, which is vastly different from client-side scripting. Check out W3S tutorial on PHP to get started.

编辑:我建议您选择免费的共享托管或在您的PC上本地构建网络服务器。检查WampServer或XAMPP在本地运行服务器,或google任何免费php mysql webhosting。

I recommend you to pick up a free shared hosting or build a webserver locally on your PC. Check out WampServer or XAMPP for running server locally, or google any free php mysql webhosting.

这篇关于将简单的列表服务器边/差存储到localstorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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