Welcom to 评论 - lizhenqiu blog!
#742
#743
#744
<script> ajax('get','https://lizhenqiu.com/xcxrequest.php','1',successf); function successf(s){ alert(s); } function ajax(method, url, data, success) { var xhr = null; try { xhr = new XMLHttpRequest();//new一个xhr对象,这个对象像信使一样存在着 } catch (e) { xhr = new ActiveXObject('Microsoft.XMLHTTP');//为了兼容IE6 } //如果是get请求,而且data存在,则是要通过get请求发送数据,通过get请求发送数据,数据会被链接到请求地址之后 if (method == 'get' && data) { url += '?' + data; } //初始化请求,method表示请求方式,url是请求地址,true表示异步 xhr.open(method,url,true); if (method == 'get') { xhr.send();//发送请求 } else { xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');//post方式,需要设置请求头 xhr.send(data);//发送提交数据 } xhr.onreadystatechange = function() { if ( xhr.readyState == 4 ) {//4是请求最后的阶段, //http状态码,2开头便是还请求成功 if ( xhr.status == 200 ) { success && success(xhr.responseText);//在这里判断一下,如果success存在,则执行它,将响应数据作为参数传入回调函数 } else { alert('出错了,Err:' + xhr.status); } } } } </script>
#745
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{ margin:0; padding:0; } div{ width:520px; height:280px; position:relative; background:pink; margin:0 auto; overflow:hidden; } div ul{ width:3640px; position:absolute; left:-520px; } div ul li{ list-style:none; float:left; width:520px; height:280px; font-size:30px; text-align:center; line-height:280px; } .prev ,.next{ width:30px; height:50px; position:absolute; background:rgba(0,0,0,.4); top:115px; } .prev:hover,.next:hover{ background:rgba(0,0,0,.6); } .prev{ left:0; } .next{ right:0; } .prev:after{ content:'<'; color:#fff; line-height:50px; text-align:center; width:100%; height:100%; display:inline-block; } .next:after{ content:'>'; color:#fff; line-height:50px; text-align:center; width:100%; height:100%; display:inline-block; } div ol{ position:absolute; bottom:10px; left:50%; margin-left:-50px; background:rgba(255,255,255,.2); } div ol li{ list-style:none; float:left; color:#fff; width:10px; height:10px; border-radius:100%; background-color:#fff; overflow:hidden; text-indent:10000px; margin:0 5px; cursor:pointer; } .orange{ background-color:orange!important; } </style> </head> <body> <div id="box"> <ul> <li><img src="https://img.alicdn.com/simba/img/TB1SYOGggLD8KJjSszeSuuGRpXa.jpg" /></li> <li><img src="https://aecpm.alicdn.com/tfscom/TB1eCWYbS_I8KJjy0FoXXaFnVXa.jpg" /></li> <li><img src="https://img.alicdn.com/tfs/TB1Pp2IfDnI8KJjy0FfXXcdoVXa-520-280.png_q90_.webp" /></li> <li><img src="https://img.alicdn.com/simba/img/TB1gWrUXfTM8KJjSZFDSuultXXa.jpg" /></li> <li><img src="https://img.alicdn.com/simba/img/TB10TmIgcnI8KJjSsziSuv8QpXa.jpg" /></li> <li><img src="https://img.alicdn.com/simba/img/TB1SYOGggLD8KJjSszeSuuGRpXa.jpg" /></li> <li><img src="https://aecpm.alicdn.com/tfscom/TB1eCWYbS_I8KJjy0FoXXaFnVXa.jpg" /></li> </ul> <a class="prev" href="javascript:void(0)"></a> <a class="next"href="javascript:void(0)"></a> <ol> <li class="orange">1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ol> </div> </body> </html> <script> var ul=document.querySelector("#box ul"); var currentValue=Number(getStyle(ul,"left").replace("px","")); var li =document.querySelectorAll("#box ul li"); var width=Number(getStyle(li[0],"width").replace("px","")); var prev=document.querySelector(".prev"); var next=document.querySelector(".next"); var ol=document.querySelector("#box ol"); var oli=document.querySelectorAll("#box ol li"); function Move(obj){ var _this=this; this.decoration=obj.decoration||null; this.count=0; this.init=function(changeValue){ ul.style.left=changeValue+"px"; }; this.action=function(){ var timer=setInterval(function(){ if(_this.decoration=="left"){ _this.count-=10; currentValue-=10; }else if(_this.decoration=="right"){ _this.count+=10; currentValue+=10; } if(currentValue==0){ currentValue=-width*(li.length-2); } if(currentValue==(li.length-1)*-width){ currentValue=-width; } var index=Math.abs(currentValue/width)-1; if(index>=li.length-(2+1)){ index=parseInt(index); } _this.olmove(Math.ceil(index)); _this.init(currentValue); if(Math.abs(_this.count)==width){ clearInterval(timer); } },1) }; this.olmove=function(index){ for(var j=0;j<oli.length;j++){ oli[j].className=""; } oli[Math.ceil(index)].className="orange"; }; this.olclick=function(){ var arrays=new Array(oli.length); for(var i=0;i<oli.length;i++){ arrays[i]=-(width*(i+1)); (function(i){ oli[i].onclick=function(){ _this.olmove(i); var timer=setInterval(function(){ if(arrays[i]<currentValue){ if(currentValue-arrays[i]>width){ currentValue-=30; }else{ currentValue-=10; } }else if(arrays[i]>currentValue){ if(arrays[i]-currentValue>width){ currentValue+=30; }else{ currentValue+=10; } } if(arrays[i]==currentValue){ clearInterval(timer) } _this.init(currentValue); },1); } }(i)); } }; } function getStyle(element,attr){ if(element.currentstyle){ return element.currentstyle[attr]; }else{ return window.getComputedStyle(element,null)[attr]; } } prev.onclick=function(){ var obj={ decoration:"right", } run(obj) } next.onclick=function(){ var obj={ decoration:"left", } run(obj) } function run(obj){ var move=new Move(obj); move.action(); } var obj={} var move=new Move(obj); move.olclick(); </script>
#746
#747
iTunes Library.itl
#748
#749
#750
<a href="#" style="color:white; text-decoration:none;" onmouseover="this.style.cssText='color:gray; text-decoration:none;'" onmouseout="this.style.cssText='color:white;text-decoration:none'">iswtf<a>
#751
<?php $akId = "*************"; $akSecret = "******************"; //更新api信息 $url = "https://shujuapi.aliyun.com/org_code/service_code/api_name?param1=xxx¶m2=xxx"; $options = array( 'http' => array( 'header' => array( 'accept'=> "application/json", 'content-type'=> "application/json", 'date'=> gmdate("D, d M Y H:i:s \G\M\T"), 'authorization' => '' ), 'method' => "GET", //可以是 GET, POST, DELETE, PUT 'content' => '' //如有数据,请用json_encode()进行编码 ) ); $http = $options['http']; $header = $http['header']; $urlObj = parse_url($url); if(empty($urlObj["query"])) $path = $urlObj["path"]; else $path = $urlObj["path"]."?".$urlObj["query"]; $body = $http['content']; if(empty($body)) $bodymd5 = $body; else $bodymd5 = base64_encode(md5($body,true)); $stringToSign = $http['method']."\n".$header['accept']."\n".$bodymd5."\n".$header['content-type']."\n".$header['date']."\n".$path; $signature = base64_encode( hash_hmac( "sha1", $stringToSign, $akSecret, true)); $authHeader = "Dataplus "."$akId".":"."$signature"; $options['http']['header']['authorization'] = $authHeader; $options['http']['header'] = implode( array_map( function($key, $val){ return $key.":".$val."\r\n"; }, array_keys($options['http']['header']), $options['http']['header'])); $context = stream_context_create($options); $file = file_get_contents($url, false, $context ); echo($file);
$json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=json_decode($res,true);
mixed json_decode ( string $json [, bool $assoc ] ) assoc 当该参数为 TRUE 时,将返回 array 而非 object 。 string json_encode ( mixed $value [, int $options = 0 ] ) 返回 value 值的 JSON 形式 Report a bug 参数 value 待编码的 value ,除了resource 类型之外,可以为任何数据类型 该函数只能接受 UTF-8 编码的数据 options 由以下常量组成的二进制掩码: JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_UNESCAPED_UNICODE. Report a bug 返回值 编码成功则返回一个以 JSON 形式表示的 string 或者在失败时返回 FALSE 。
#752
#753
#754
#755
#756
#757
<?php /** * PHP发送Json对象数据 * * @param $url 请求url * @param $jsonStr 发送的json字符串 * @return array */ function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($jsonStr) ) ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array($httpCode, $response); } $url = "http://52php.cnblogs.com"; $jsonStr = json_encode(array('a' => 1, 'b' => 2, 'c' => 2)); list($returnCode, $returnContent) = http_post_json($url, $jsonStr);
#758
#759
#760
text-align: justify; word-break: break-word;
确定要清除编辑框内容吗?
该删除操作将不可恢复。
删除 取消
激活Windows
转到"设置"以激活Windows。
#742
#743
#744
<script> ajax('get','https://lizhenqiu.com/xcxrequest.php','1',successf); function successf(s){ alert(s); } function ajax(method, url, data, success) { var xhr = null; try { xhr = new XMLHttpRequest();//new一个xhr对象,这个对象像信使一样存在着 } catch (e) { xhr = new ActiveXObject('Microsoft.XMLHTTP');//为了兼容IE6 } //如果是get请求,而且data存在,则是要通过get请求发送数据,通过get请求发送数据,数据会被链接到请求地址之后 if (method == 'get' && data) { url += '?' + data; } //初始化请求,method表示请求方式,url是请求地址,true表示异步 xhr.open(method,url,true); if (method == 'get') { xhr.send();//发送请求 } else { xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');//post方式,需要设置请求头 xhr.send(data);//发送提交数据 } xhr.onreadystatechange = function() { if ( xhr.readyState == 4 ) {//4是请求最后的阶段, //http状态码,2开头便是还请求成功 if ( xhr.status == 200 ) { success && success(xhr.responseText);//在这里判断一下,如果success存在,则执行它,将响应数据作为参数传入回调函数 } else { alert('出错了,Err:' + xhr.status); } } } } </script>
防止缓存的方法:
请求的url地址?t=new Date()
POST 方式请求
浏览器认为Post的提交必然是有改变的 所以一般post请求 不会从缓存中去数据
不管是哪中方式请求 我们可以设置缓存开关:
$ajax.Setup({ cache:false});
encodeURL()处理中文乱码问题
#745
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style> *{ margin:0; padding:0; } div{ width:520px; height:280px; position:relative; background:pink; margin:0 auto; overflow:hidden; } div ul{ width:3640px; position:absolute; left:-520px; } div ul li{ list-style:none; float:left; width:520px; height:280px; font-size:30px; text-align:center; line-height:280px; } .prev ,.next{ width:30px; height:50px; position:absolute; background:rgba(0,0,0,.4); top:115px; } .prev:hover,.next:hover{ background:rgba(0,0,0,.6); } .prev{ left:0; } .next{ right:0; } .prev:after{ content:'<'; color:#fff; line-height:50px; text-align:center; width:100%; height:100%; display:inline-block; } .next:after{ content:'>'; color:#fff; line-height:50px; text-align:center; width:100%; height:100%; display:inline-block; } div ol{ position:absolute; bottom:10px; left:50%; margin-left:-50px; background:rgba(255,255,255,.2); } div ol li{ list-style:none; float:left; color:#fff; width:10px; height:10px; border-radius:100%; background-color:#fff; overflow:hidden; text-indent:10000px; margin:0 5px; cursor:pointer; } .orange{ background-color:orange!important; } </style> </head> <body> <div id="box"> <ul> <li><img src="https://img.alicdn.com/simba/img/TB1SYOGggLD8KJjSszeSuuGRpXa.jpg" /></li> <li><img src="https://aecpm.alicdn.com/tfscom/TB1eCWYbS_I8KJjy0FoXXaFnVXa.jpg" /></li> <li><img src="https://img.alicdn.com/tfs/TB1Pp2IfDnI8KJjy0FfXXcdoVXa-520-280.png_q90_.webp" /></li> <li><img src="https://img.alicdn.com/simba/img/TB1gWrUXfTM8KJjSZFDSuultXXa.jpg" /></li> <li><img src="https://img.alicdn.com/simba/img/TB10TmIgcnI8KJjSsziSuv8QpXa.jpg" /></li> <li><img src="https://img.alicdn.com/simba/img/TB1SYOGggLD8KJjSszeSuuGRpXa.jpg" /></li> <li><img src="https://aecpm.alicdn.com/tfscom/TB1eCWYbS_I8KJjy0FoXXaFnVXa.jpg" /></li> </ul> <a class="prev" href="javascript:void(0)"></a> <a class="next"href="javascript:void(0)"></a> <ol> <li class="orange">1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ol> </div> </body> </html> <script> var ul=document.querySelector("#box ul"); var currentValue=Number(getStyle(ul,"left").replace("px","")); var li =document.querySelectorAll("#box ul li"); var width=Number(getStyle(li[0],"width").replace("px","")); var prev=document.querySelector(".prev"); var next=document.querySelector(".next"); var ol=document.querySelector("#box ol"); var oli=document.querySelectorAll("#box ol li"); function Move(obj){ var _this=this; this.decoration=obj.decoration||null; this.count=0; this.init=function(changeValue){ ul.style.left=changeValue+"px"; }; this.action=function(){ var timer=setInterval(function(){ if(_this.decoration=="left"){ _this.count-=10; currentValue-=10; }else if(_this.decoration=="right"){ _this.count+=10; currentValue+=10; } if(currentValue==0){ currentValue=-width*(li.length-2); } if(currentValue==(li.length-1)*-width){ currentValue=-width; } var index=Math.abs(currentValue/width)-1; if(index>=li.length-(2+1)){ index=parseInt(index); } _this.olmove(Math.ceil(index)); _this.init(currentValue); if(Math.abs(_this.count)==width){ clearInterval(timer); } },1) }; this.olmove=function(index){ for(var j=0;j<oli.length;j++){ oli[j].className=""; } oli[Math.ceil(index)].className="orange"; }; this.olclick=function(){ var arrays=new Array(oli.length); for(var i=0;i<oli.length;i++){ arrays[i]=-(width*(i+1)); (function(i){ oli[i].onclick=function(){ _this.olmove(i); var timer=setInterval(function(){ if(arrays[i]<currentValue){ if(currentValue-arrays[i]>width){ currentValue-=30; }else{ currentValue-=10; } }else if(arrays[i]>currentValue){ if(arrays[i]-currentValue>width){ currentValue+=30; }else{ currentValue+=10; } } if(arrays[i]==currentValue){ clearInterval(timer) } _this.init(currentValue); },1); } }(i)); } }; } function getStyle(element,attr){ if(element.currentstyle){ return element.currentstyle[attr]; }else{ return window.getComputedStyle(element,null)[attr]; } } prev.onclick=function(){ var obj={ decoration:"right", } run(obj) } next.onclick=function(){ var obj={ decoration:"left", } run(obj) } function run(obj){ var move=new Move(obj); move.action(); } var obj={} var move=new Move(obj); move.olclick(); </script>
#746
#747
itunes清楚视频库记录
删除电脑中iTunes的影片记录
找到itunes library文件 删掉就可以了
iTunes Library.itl
#748
#749
#750
<a href="#" style="color:white; text-decoration:none;" onmouseover="this.style.cssText='color:gray; text-decoration:none;'" onmouseout="this.style.cssText='color:white;text-decoration:none'">iswtf<a>
#751
图像打标API调用
场景识别API调用
请求参数,以json格式放置于Https Body内
<?php $akId = "*************"; $akSecret = "******************"; //更新api信息 $url = "https://shujuapi.aliyun.com/org_code/service_code/api_name?param1=xxx¶m2=xxx"; $options = array( 'http' => array( 'header' => array( 'accept'=> "application/json", 'content-type'=> "application/json", 'date'=> gmdate("D, d M Y H:i:s \G\M\T"), 'authorization' => '' ), 'method' => "GET", //可以是 GET, POST, DELETE, PUT 'content' => '' //如有数据,请用json_encode()进行编码 ) ); $http = $options['http']; $header = $http['header']; $urlObj = parse_url($url); if(empty($urlObj["query"])) $path = $urlObj["path"]; else $path = $urlObj["path"]."?".$urlObj["query"]; $body = $http['content']; if(empty($body)) $bodymd5 = $body; else $bodymd5 = base64_encode(md5($body,true)); $stringToSign = $http['method']."\n".$header['accept']."\n".$bodymd5."\n".$header['content-type']."\n".$header['date']."\n".$path; $signature = base64_encode( hash_hmac( "sha1", $stringToSign, $akSecret, true)); $authHeader = "Dataplus "."$akId".":"."$signature"; $options['http']['header']['authorization'] = $authHeader; $options['http']['header'] = implode( array_map( function($key, $val){ return $key.":".$val."\r\n"; }, array_keys($options['http']['header']), $options['http']['header'])); $context = stream_context_create($options); $file = file_get_contents($url, false, $context ); echo($file);
$json3=json_encode($jsonArr,JSON_UNESCAPED_UNICODE); $res=json_decode($res,true);
mixed json_decode ( string $json [, bool $assoc ] ) assoc 当该参数为 TRUE 时,将返回 array 而非 object 。 string json_encode ( mixed $value [, int $options = 0 ] ) 返回 value 值的 JSON 形式 Report a bug 参数 value 待编码的 value ,除了resource 类型之外,可以为任何数据类型 该函数只能接受 UTF-8 编码的数据 options 由以下常量组成的二进制掩码: JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_UNESCAPED_UNICODE. Report a bug 返回值 编码成功则返回一个以 JSON 形式表示的 string 或者在失败时返回 FALSE 。
#752
吴王好剑客,百姓多疮瘢。
楚王好细腰,宫中多饿死。
#753
#754
#755
#756
#757
需要发送一个 http Content-Type头信息,即 “Content-Type: application/json; charset=utf-8”
<?php /** * PHP发送Json对象数据 * * @param $url 请求url * @param $jsonStr 发送的json字符串 * @return array */ function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($jsonStr) ) ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array($httpCode, $response); } $url = "http://52php.cnblogs.com"; $jsonStr = json_encode(array('a' => 1, 'b' => 2, 'c' => 2)); list($returnCode, $returnContent) = http_post_json($url, $jsonStr);
#758
#759
#760
text-align: justify; word-break: break-word;