随笔分类 -  jquery

摘要:发现一种改动最小也能实现跨域请求的方法 服务端 服务端修改web.xml配置文件, 增加过滤器 (不用导入任何jar包, 用的tomcat自带jar) 服务端controller使用@RequestBody来获取参数 客户端 使用jquery的ajax, 设置crossDomain为true, 允许 阅读全文
posted @ 2017-03-09 15:56 周雷 阅读(4699) 评论(0) 推荐(0)
摘要:应用场景 调用百度的某个API, 例如:https://openapi.baidu.com/api 返回结果是:{"id":123,"name":"test"} 用$.ajax直接调用的话, 会提示 如果返回结果是var obj={"id":123,"name":"test"}; 只需要jsonp就 阅读全文
posted @ 2017-02-08 18:39 周雷 阅读(2220) 评论(0) 推荐(1)
摘要:前提是,不能跨域访问引入jquery库在$(function(){});中加入以下代码: $.ajax({ url : playlist[0].mp3, type : 'HEAD', error : function() { al... 阅读全文
posted @ 2014-11-28 11:05 周雷 阅读(4953) 评论(0) 推荐(0)
摘要:有三个select下拉框一个大类,两个小类隐藏,需要在选择大类的时候,小类显示同时清除另外的小类选择的项这需求有点儿..........下面是三个select: jquery扩展,调用时,使用$("select").removeSelected(); 大类选择框选中时,调用selectFunctio 阅读全文
posted @ 2013-08-21 17:48 周雷 阅读(36468) 评论(0) 推荐(0)
摘要:使用360chrome和google chrome浏览器加载本地html文件时,会报错,提示: XMLHttpRequest cannot load file:///Y:/jswg/code/html/grid/info/s9.html. Origin null is not allowed by Access-Control-Allow-Origin.解决方法,在浏览器启动命令后加参数:"--args -disable-web-security"在chrome.exe的快捷方式上,右键->属性->目标后加上参数,例:"C:\Users\zyl\App 阅读全文
posted @ 2013-07-11 11:35 周雷 阅读(3338) 评论(0) 推荐(0)
摘要:1.获取页面上所有a标签的同胞元素:// 获取所有class不为a1的a标签$("a.a1").siblings();// 获取所有class不为a1,并且class中包含a2的a标签:$("a.a1").siblings(".a2");2.jquery获取class="wai_tab"的table第二列,行号大于1的单元格(从零开始),并循环: var contents = $(".wai_tab tr:gt(1)"); $.each(contents,function(i,value){ v 阅读全文
posted @ 2013-07-01 09:41 周雷 阅读(340) 评论(0) 推荐(0)
摘要:看到一个在地图上的特效,就是标注当前位置之后,图标一直在跳动,那效果看着比较得劲,就自己写了个图标跳动的jsjs代码: setTimeout("jump()",5); var t=0,a=10,v=t*a,s=30,updown=true;// s路程,a加速度,t时间,updown判断上升还是下降 function jump(){ if(t<=0){ updown=true; }else if(t*t*a>=s){ ... 阅读全文
posted @ 2013-06-01 17:06 周雷 阅读(4398) 评论(0) 推荐(0)
摘要:如题,很让人郁闷的一个错误,开始还以为json格式错了呢后台代码:response.setCharacterEncoding("UTF-8");// 设置编码response.setContentType("text/plain");// 加上这句,设置文档类型response.getWriter().write(json);// 输出json还有在网上看到的说法是修改ajax中的xmlHttpObject.overrideMimeType('text/xml');这句代码真木有找拙在哪 阅读全文
posted @ 2013-04-19 14:26 周雷 阅读(283) 评论(0) 推荐(0)
摘要:本例子使用json数据,拼接ul和li来实现的效果图:1.准备json数据:View Code 1 var menuData = [ 2 {id:0,pid:-1,name:"订购产品",url:"",children:[ 3 {id:1,pid:0,name:"电脑配件",url:"http://www.baidu.com",children:[ 4 {id:20,pid:1,name:"cpu",url:"http://www.baidu.com",children:[ 阅读全文
posted @ 2013-03-07 15:35 周雷 阅读(1974) 评论(0) 推荐(2)
摘要:前提是图片路径是正确的... var img = new Image(); img.src="http://www.baidu.com/img/baidu_sylogo1.gif"; img.onload = function(){ alert(this.width)... 阅读全文
posted @ 2012-04-20 17:25 周雷 阅读(1903) 评论(0) 推荐(0)
摘要:jquery代码:$(function(){ $("#test").load("${contextPath}/notepad/toCreate.do");}加载 ${contextPath}/notepad/toCreate.do 页面到id为test的div中,加载完成之后,create页面中的js不会执行这种方式没办法实现,换个思路:<div id="test"> <iframe name="testLoad" style="width:100%"></ifra 阅读全文
posted @ 2011-12-16 16:00 周雷 阅读(5963) 评论(0) 推荐(0)
摘要:在做页面设计的时候,有时需要在一个页面上引入另一个页面,用jquery比较简单,三两句代码就能实现,看代码:index.html<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF- 阅读全文
posted @ 2011-12-13 10:04 周雷 阅读(6387) 评论(0) 推荐(0)
摘要:索引 1.checkbox相关操作 2.js强制按数字计算 3.jquery将字符串转换为json对象 4.jquery获取选中radio值 5.jquery简单的奇偶行变色 6.jquery获取radio选中值 7.js操作json集合 8.jquery彻底清除dom元素 9.jquery延迟mo 阅读全文
posted @ 2011-11-26 22:53 周雷 阅读(1353) 评论(0) 推荐(0)

友情链接