Javascript Web Design
2016-04-24 22:23
363 查看
1. 在HTML call 在javascript里的 function
2. 在javascript里使用 html 里的id, id 不能是大写开头,否则会出现Error。
3. 使用php 与 Ajax 时,发送键不能为html里内建的submit,否则 将不能使Ajax成功连接上(TextStatus:Request failed: error)需要的url。
此外使用内建submit,有不好处:会造成request泄漏,submit后,会默认将form的内容serialize到当前地址的后缀处(以?开始)。
正确:<input type="button" name="submit" id="" onclick="userInput()"/>
不当:<input type="submit" name="submit" id="" onclick="userInput()"/>
4. PHP 里的variable 用 "Get" 得到 undefined error:
在PHP 的function 里用 global scope。 如:
global $year; echo($year);
<input type="text" name="from" id="from" maxlength="5" placeholder="day-month" title="Optional" onkeyup="checkDate(this)"/>
function checkDate(caller){ var that = $(caller); if(caller.id == 'from' || caller.id == 'to'){ if(caller.value.match(/^[0-9 -]+$/g)){that.css('border','none');} else if(caller.value == ""){that.css('border','none');}else{that.css('border','red 1px solid');} }
2. 在javascript里使用 html 里的id, id 不能是大写开头,否则会出现Error。
3. 使用php 与 Ajax 时,发送键不能为html里内建的submit,否则 将不能使Ajax成功连接上(TextStatus:Request failed: error)需要的url。
此外使用内建submit,有不好处:会造成request泄漏,submit后,会默认将form的内容serialize到当前地址的后缀处(以?开始)。
正确:<input type="button" name="submit" id="" onclick="userInput()"/>
不当:<input type="submit" name="submit" id="" onclick="userInput()"/>
4. PHP 里的variable 用 "Get" 得到 undefined error:
在PHP 的function 里用 global scope。 如:
global $year; echo($year);
相关文章推荐
- js关于setTimeout实现延时执行函数并进行传参
- jsp 输出 json
- Javascript
- IT忍者神龟之JsUnit测试JS
- javaScript文件位置调整
- js笔记
- 利用Three.js构建粒子系统
- IT忍者神龟之Javascript开发工具
- 原生JS实现"旋转木马"效果的图片轮播插件
- phantomjs server + highchart 在服务器端生成highchart图表图片
- js传递参数中文乱码
- Javascript遍历Html Table示例(包括内容和属性值)
- javascript字母大小写转换的4个函数详解
- javascript 正则表达式 获取全部分组内容
- Javascript中函数调用和this的关系
- JavaEE编程技术(JSP/Servlet)
- jstl的formatNumber标签的四舍五入问题
- 亲爱的!直接建此类传一个URL即可得到json串非常方便
- Move.js
- jsp页面上做判断