jQuery-PHP跨域请求数据

jQuery:

 1 //获取域名
 2 function getDomain(url){
 3     var a = document.createElement('a');
 4     a.href = url;
 5     url=a.hostname;
 6     return url;
 7 }
 8 
 9 //记录访客
10 function recordVisitor(){
11     var referrerMz = escape(getDomain(document.referrer));
12     var hrefMz = escape(getDomain(window.location.href));
13     sendInfo="judgeMz=413322&referrerMz="+escape(referrerMz)+"&hrefMz="+escape(hrefMz);
14     $.ajax({ 
15         type: "get", 
16         async: true, 
17         url: "http://www.mazey.net/config/api/record-receive.php", 
18         data:{judgeMz:413322,referrerMz:referrerMz,hrefMz:hrefMz}, 
19         dataType: "jsonp", 
20         jsonp: "callback",
21         jsonpCallback:"returnFun",
22         success: function(data){ 
23             myArr=data.split("-|-")
24             if("0507"==myArr[0]){
25                 console.log(myArr[1]);
26             }else if("0215"==myArr[0]){
27                 console.log(myArr[1]);
28             }
29         }, 
30         error: function(){ 
31             console.log("Server Error!");
32         } 
33     });
34 }
35 
36 //加载
37 $(document).ready(function () { 
38     recordVisitor();
39 });

PHP:

 1 <?php
 2 require '../config.php';
 3 $judgeMz=$_GET["judgeMz"];//TODO 后续做一个验证不是413322的报错
 4 $referrerMz=$_GET["referrerMz"];
 5 $hrefMz=$_GET["hrefMz"];
 6 $visitorIP=getIP();
 7 
 8 $data = returnFun($referrerMz,$hrefMz,$visitorIP); 
 9 exit($_GET['callback'] . '(' . json_encode($data) . ')'); 
10 
11 function returnFun($referrerMz,$hrefMz,$visitorIP) { 
12     $urlRecordVisitor='http://www.mazey.cn/config/config-asp/api/record-receive.asp?referrerMz='.$referrerMz.'&hrefMz='.$hrefMz.'&visitorIP='.$visitorIP;
13     $resultMz = file_get_contents($urlRecordVisitor);
14     return $resultMz;
15 }
16 ?>

其他:

因为http://www.mazey.cn/config/config-asp/api/record-receive.asp在国内,所以访问起来好像有点慢。准备按照asp重写下php的后端写入代码,本来计划了不少事情,其他事情这一步做完以后再说吧。

jQuery获取input复选框的值

var ipResolveValue =[]; //定义一个空数组
$("input[name='ipResolve']:checked").each(function(){   //each为每个匹配元素规定运行的函数,匹配name="ipResolve"的复选框
ipResolveValue.push($(this).val()); //js push增加数组值
});
//alert(ipResolveValue.length==0 ?'你还没有选择任何内容!':ipResolveValue);

ASP-Command-SQL格式

conn.open constr
Set c=Server.CreateObject("ADODB.Command")
With c
Set .ActiveConnection = conn
.CommandType = 1
.CommandText = "Select -- from -- where --=?"
.Parameters.Append .CreateParameter("@--",200,1,20,--)
set rs=.Execute()
End With
Set c.ActiveConnection = Nothing
set c=nothing
If Not rs.eof Then
--
End If
rs.close
conn.close

ASP连接数据库SQLServer

Set conn=Server.CreateObject("adodb.connection")
Set conn1=Server.CreateObject("adodb.connection")
Set rs=Server.CreateObject("adodb.Recordset")
Set cmd=Server.CreateObject("adodb.Command")

db_host="127.0.0.1"
db_name="mazey_name"
db_user="mazey_user"
db_pass="mazey_password"

constr="provider=sqloledb;initial catalog=" & db_name
constr=constr & "; data source=" & db_host
constr=constr & ";user id=" & db_user
constr=constr & ";password=" & db_pass

conn.connectionstring=constr
conn1.connectionstring=constr

CSS图片居中,多余隐藏

/*外层DIV*/

div {position: relative;overflow:hidden;width: 显示宽度px;}

/*left=50%刚好在中间,margin-left=往前移动图片一半,这是图片就是居中了*/

img {border:none;width: 图片宽度px;position:absolute;top:0;left:50%;margin-left: -图片宽度一半px;}

实测margin-left:-?px;需要调试。