简单的ajax记事本
记事本,同时只能记录一个文件,存为了txt文本文档
注意本例用了一些css和js文件,请在演示页面另存为后查看

PHP Code
- <?php
- $note_name = 'note.txt';
- $uniqueNotePerIP = true;
- if($uniqueNotePerIP){
- // Use the user's IP as the name of the note.
- // This is useful when you have many people
- // using the app simultaneously.
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
- $note_name = 'notes/'.md5($_SERVER['HTTP_X_FORWARDED_FOR']).'.txt';
- }
- else{
- $note_name = 'notes/'.md5($_SERVER['REMOTE_ADDR']).'.txt';
- }
- }
- if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){
- // This is an AJAX request
- if(isset($_POST['note'])){
- // Write the file to disk
- file_put_contents($note_name, $_POST['note']);
- echo '{"saved":1}';
- }
- exit;
- }
- $note_content = '
- Write your note here.
- It will be saved with AJAX.';
- if( file_exists($note_name) ){
- $note_content = htmlspecialchars( file_get_contents($note_name) );
- }
- ?>
XML/HTML Code
- <div id="pad">
- <h2>Note</h2>
- <textarea id="note"><?php echo $note_content ?></textarea>
- </div>
原文地址:http://www.freejs.net/article_jquerywenzi_68.html
最近更新
- 响应式全屏手风琴菜单,同时支持垂直方...
- 分组select选择器,支持多选和单...
- jQuery时间日期选择器代码日历插...
- Select 选择器 可以清空的单选...
- jQuery json 无刷新翻页 ...
- 纯css3带倒影效果的图片翻转特效
我爱薅羊毛
点击最多
广告赞助
相关文章
- jquery点击显示或隐藏内容,可以一次展开多个和...
- tooltips/弹出层/消息提示效果,支持点击与...
- jQuery幸运大转盘抽奖活动代码
- jquery来实现的添加商品和减少商品数量,用于购...
- jQuery手机端弹出层提示对话框
- php js实现拖动滑块完成拼图验证码