概述

1、传统的Web应用

一个简单操作需要重新加载全局数据

2、AJAX

AJAX,Asynchronous JavaScript and XML (异步的JavaScript和XML),一种创建交互式网页应用的网页开发技术方案。

  • 异步的JavaScript:
    使用 【JavaScript语言】 以及 相关【浏览器提供类库】 的功能向服务端发送请求,当服务端处理完请求之后,【自动执行某个JavaScript的回调函数】。
    PS:以上请求和响应的整个过程是【偷偷】进行的,页面上无任何感知。
  • XML
    XML是一种标记语言,是Ajax在和后台交互时传输数据的格式之一

利用AJAX可以做:
1、注册时,输入用户名自动检测用户是否已经存在。
2、登陆时,提示用户名密码错误
3、删除数据行时,将行ID发送到后台,后台在数据库中删除,数据库删除成功后,在页面DOM中将数据行也删除。(博客园)

“伪”AJAX

由于HTML标签的iframe标签具有局部加载内容的特性,所以可以使用其来伪造Ajax请求。

iframe.src 重新加载,页面不刷新

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div>
<p>请输入要加载的地址:<span id="currentTime"></span></p>
<p>
<input id="url" type="text" />
<input type="button" value="刷新" onclick="LoadPage();">
</p>
</div> <div>
<h3>加载页面位置:</h3>
<iframe id="iframePosition" style="width: 100%;height: 500px;"></iframe>
</div> <script type="text/javascript"> window.onload= function(){
var myDate = new Date();
document.getElementById('currentTime').innerText = myDate.getTime();
};
function LoadPage(){
var targetUrl = document.getElementById('url').value;
document.getElementById("iframePosition").src = targetUrl;
}
</script>
</body>
</html>

原生AJAX

Ajax主要就是使用 【XmlHttpRequest】对象来完成请求的操作,该对象在主流浏览器中均存在(除早起的IE),Ajax首次出现IE5.5中存在(ActiveX控件)。

1、XmlHttpRequest对象介绍

XmlHttpRequest对象的主要方法:

a. void open(String method,String url,Boolen async)
用于创建请求 参数:
method: 请求方式(字符串类型),如:POST、GET、DELETE...
url: 要请求的地址(字符串类型)
async: 是否异步(布尔类型) b. void send(String body)
用于发送请求 参数:
body: 要发送的数据(字符串类型) c. void setRequestHeader(String header,String value)
用于设置请求头 参数:
header: 请求头的key(字符串类型)
vlaue: 请求头的value(字符串类型) d. String getAllResponseHeaders()
获取所有响应头 返回值:
响应头数据(字符串类型) e. String getResponseHeader(String header)
获取响应头中指定header的值 参数:
header: 响应头的key(字符串类型) 返回值:
响应头中指定的header对应的值 f. void abort() 终止请求

XmlHttpRequest对象的主要属性:

a. Number readyState
状态值(整数) 详细:
0-未初始化,尚未调用open()方法;
1-启动,调用了open()方法,未调用send()方法;
2-发送,已经调用了send()方法,未接收到响应;
3-接收,已经接收到部分响应数据;
4-完成,已经接收到全部响应数据; b. Function onreadystatechange
当readyState的值改变时自动触发执行其对应的函数(回调函数) c. String responseText
服务器返回的数据(字符串类型) d. XmlDocument responseXML
服务器返回的数据(Xml对象) e. Number states
状态码(整数),如:200、404... f. String statesText
状态文本(字符串),如:OK、NotFound...

2、跨浏览器支持

  • XmlHttpRequest

    IE7+, Firefox, Chrome, Opera, etc.

  • ActiveXObject("Microsoft.XMLHTTP")

    IE6, IE5

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body> <h1>XMLHttpRequest - Ajax请求</h1>
<input type="button" onclick="XmlGetRequest();" value="Get发送请求" />
<input type="button" onclick="XmlPostRequest();" value="Post发送请求" /> <script src="/statics/jquery-1.12.4.js"></script>
<script type="text/javascript"> function GetXHR(){
var xhr = null;
if(XMLHttpRequest){
xhr = new XMLHttpRequest();
}else{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr; } function XhrPostRequest(){
var xhr = GetXHR();
// 定义回调函数
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
// 已经接收到全部响应数据,执行以下操作
var data = xhr.responseText;
console.log(data);
}
};
// 指定连接方式和地址----文件方式
xhr.open('POST', "/test/", true);
// 设置请求头
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset-UTF-8');
// 发送请求
xhr.send('n1=1;n2=2;');
} function XhrGetRequest(){
var xhr = GetXHR();
// 定义回调函数
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
// 已经接收到全部响应数据,执行以下操作
var data = xhr.responseText;
console.log(data);
}
};
// 指定连接方式和地址----文件方式
xhr.open('get', "/test/", true);
// 发送请求
xhr.send();
} </script> </body>
</html>

基于原生Ajax-demo

原生ajax发送post请求要带上请求头

xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset-UTF-8');

jQuery Ajax

jQuery其实就是一个JavaScript的类库,其将复杂的功能做了上层封装,使得开发者可以在其基础上写更少的代码实现更多的功能。

  • jQuery 不是生产者,而是大自然搬运工。
  • jQuery Ajax本质 XMLHttpRequest 或 ActiveXObject

注:2.+版本不再支持IE9以下的浏览器

            jQuery.get(...)
所有参数:
url: 待载入页面的URL地址
data: 待发送 Key/value 参数。
success: 载入成功时回调函数。
dataType: 返回内容格式,xml, json, script, text, html jQuery.post(...)
所有参数:
url: 待载入页面的URL地址
data: 待发送 Key/value 参数
success: 载入成功时回调函数
dataType: 返回内容格式,xml, json, script, text, html jQuery.getJSON(...)
所有参数:
url: 待载入页面的URL地址
data: 待发送 Key/value 参数。
success: 载入成功时回调函数。 jQuery.getScript(...)
所有参数:
url: 待载入页面的URL地址
data: 待发送 Key/value 参数。
success: 载入成功时回调函数。 jQuery.ajax(...) 部分参数: url:请求地址
type:请求方式,GET、POST(1.9.0之后用method)
headers:请求头
data:要发送的数据
contentType:即将发送信息至服务器的内容编码类型(默认: "application/x-www-form-urlencoded; charset=UTF-8")
async:是否异步
timeout:设置请求超时时间(毫秒) beforeSend:发送请求前执行的函数(全局)
complete:完成之后执行的回调函数(全局)
success:成功之后执行的回调函数(全局)
error:失败之后执行的回调函数(全局) accepts:通过请求头发送给服务器,告诉服务器当前客户端课接受的数据类型
dataType:将服务器端返回的数据转换成指定类型
"xml": 将服务器端返回的内容转换成xml格式
"text": 将服务器端返回的内容转换成普通文本格式
"html": 将服务器端返回的内容转换成普通文本格式,在插入DOM中时,如果包含JavaScript标签,则会尝试去执行。
"script": 尝试将返回值当作JavaScript去执行,然后再将服务器端返回的内容转换成普通文本格式
"json": 将服务器端返回的内容转换成相应的JavaScript对象
"jsonp": JSONP 格式
使用 JSONP 形式调用函数时,如 "myurl?callback=?" jQuery 将自动替换 ? 为正确的函数名,以执行回调函数 如果不指定,jQuery 将自动根据HTTP包MIME信息返回相应类型(an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string converters: 转换器,将服务器端的内容根据指定的dataType转换类型,并传值给success回调函数
$.ajax({
accepts: {
mycustomtype: 'application/x-some-custom-type'
}, // Expect a `mycustomtype` back from server
dataType: 'mycustomtype' // Instructions for how to deserialize a `mycustomtype`
converters: {
'text mycustomtype': function(result) {
// Do Stuff
return newresult;
}
},
});

Jquery Ajax-方法

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body> <p>
<input type="button" onclick="XmlSendRequest();" value='Ajax请求' />
</p> <script type="text/javascript" src="jquery-1.12.4.js"></script>
<script> function JqSendRequest(){
$.ajax({
url: "http://c2.com:8000/test/",
type: 'GET',
dataType: 'text',
success: function(data, statusText, xmlHttpRequest){
console.log(data);
}
})
} </script>
</body>
</html>

基于JqueryAjax -demo

通过ajax返回得到的字符串,可以通过  obj = JSON.parse(callback) 转换回原来格式!

跨域AJAX

由于浏览器存在同源策略机制,同源策略阻止从一个源加载的文档或脚本获取或设置另一个源加载的文档的属性。

特别的:由于同源策略是浏览器的限制,所以请求的发送和响应是可以进行,只不过浏览器不接受罢了。

浏览器同源策略并不是对所有的请求均制约:

  • 制约: XmlHttpRequest

  • 不叼: img、iframe、script等具有src属性的标签  => 相当于发送了get请求

跨域,跨域名访问,如:http://www.c1.com 域名向 http://www.c2.com域名发送请求。

1、JSONP实现跨域请求

JSONP(JSONP - JSON with Padding是JSON的一种“使用模式”),利用script标签的src属性(浏览器允许script标签跨域)

-- localhost:8889 :

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("func([11,22,33,44])") *******************************************
-- localhost:8888 : function Jsonp1(){
var tag = document.createElement('script');
tag.src = 'http://localhost:8889/index';
document.head.appendChild(tag);
document.head.removeChild(tag);
} function func(arg) {
console.log(arg)
}

Jsonp1() 被执行后,创建了一个<script> 代码块 , 填充了返回值!

<script>
func([11,22,33,44])
</script>

接着执行了 func() 输出 [11,22,33,44]

-- jQuery 实现方式:
function jsonpclick() {
$.ajax({
url:'http://localhost:8889/index',
dataType:'jsonp',
jsonpCallback:'func',
});
}

改进版:

-- localhost:8889 :

class MainHandler(tornado.web.RequestHandler):
def get(self):
callback = self.get_argument('callback')
self.write("%s([11,22,33,44])"%callback) 此时页面中,访问:
http://localhost:8889/index?callback=xxoo
http://localhost:8889/index?callback=ssss
都可以!
*******************************************
-- localhost:8888 : function func(arg) {
console.log(arg)
} function jsonpclick() {
$.ajax({
url:'http://localhost:8889/index',
dataType:'jsonp',
jsonp:'callback',
jsonpCallback:'func',
});
}

代码中相当于发送了: http://localhost:8889/index?callback=func

jsonp:要求为String类型的参数,在一个jsonp请求中重写回调函数的名字。

该值用来替代在"callback=?"这种GET或POST请求中URL参数里的"callback"部分,
例如 {jsonp:'onJsonPLoad'} 会导致将"?onJsonPLoad="传给服务器。 jsonpCallBack: 区分大小写
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Welcome !
<p>
<input type="button" onclick="Jsonp1();" value='原生'/>
</p> <button onclick="jsonpclick()" value="button1">button本地</button>
<button onclick="jsonpclickJX()" value="button2">buttonJX</button>
<button onclick="jsonpclickshort()" value="button3">buttonSHort</button>
<script src="{{ static_url('jquery-1.8.2.js') }}"></script>
<script>
function Jsonp1(){
var tag = document.createElement('script');
tag.src = 'http://localhost:8889/index';
document.head.appendChild(tag);
document.head.removeChild(tag);
}
function func(arg) {
console.log(arg)
}
function list(arg) {
console.log(arg)
}
function jsonpclick() {
$.ajax({
url:'http://localhost:8889/index',
dataType:'jsonp',
jsonpCallback:'func',
jsonp:'callback1',
});
}
function jsonpclickJX() {
$.ajax({
url:'http://www.jxntv.cn/data/jmd-jxtv2.html',
dataType:'jsonp',
jsonpCallBack:'func',
jsonp:'callback',
});
}
function jsonpclickshort() {
$.ajax({
url:'http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list',
dataType:'jsonp',
jsonpCallBack:'func',
});
}
</script>
</body>
</html>

实例: 江西电视台节目单获取

2、CORS

随着技术的发展,现在的浏览器可以支持主动设置从而允许跨域请求,

即:跨域资源共享(CORS,Cross-Origin Resource Sharing)

其本质是设置响应头,使得浏览器允许跨域请求。

* 简单请求 OR 非简单请求

条件:
1、请求方式:HEAD、GET、POST
2、请求头信息:
Accept
Accept-Language
Content-Language
Last-Event-ID
Content-Type 对应的值是以下三个中的任意一个
application/x-www-form-urlencoded
multipart/form-data
text/plain 注意:同时满足以上两个条件时,则是简单请求,否则为复杂请求

* 简单请求和非简单请求的区别?

简单请求:一次请求
非简单请求:两次请求,在发送数据之前会先发一次请求用于做“预检”,只有“预检”通过后才再发送一次请求用于数据传输。

* 关于“预检”

- 请求方式:OPTIONS
- “预检”其实做检查,检查如果通过则允许传输数据,检查不通过则不再发送真正想要发送的消息
- 如何“预检”
=> 如果复杂请求是PUT等请求,则服务端需要设置允许某请求,否则“预检”不通过
Access-Control-Request-Method
=> 如果复杂请求设置了请求头,则服务端需要设置允许某请求头,否则“预检”不通过
Access-Control-Request-Headers

基于cors实现AJAX请求:

a、支持跨域,简单请求

服务器设置响应头:Access-Control-Allow-Origin = '域名' 或 '*'

self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888,http://localhost:9999")
self.set_header('Access-Control-Allow-Origin', "*") //所有网站

实例:

function corsSimple() {
$.ajax({
url:'http://localhost:8889/index',
type:'post',
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
} ***********************************************
-- localhost:8889
def post(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
v1 = self.get_argument('v1')
print(v1)
self.write('--post--')

b、支持跨域,复杂请求

由于复杂请求时,首先会发送“预检”请求,如果“预检”成功,则发送真实数据。

  • “预检”请求时,允许请求方式则需服务器设置响应头:Access-Control-Request-Method

  • “预检”请求时,允许请求头则需服务器设置响应头:Access-Control-Request-Headers

  • “预检”缓存时间,服务器设置响应头:Access-Control-Max-Age

--localhost:8889

def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Methods', "PUT")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
print('--option--')
def put(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
print('--put--')
self.write('--put--') ***********************************************
--localhost:8888 function corscomplex() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
}

如果客户端,加上了自定义请求头,服务器端要加上

self.set_header('Access-Control-Allow-Headers', "key1,key2")

实例:

--localhost:8889

def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Methods', "PUT")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Headers', "key1,key2")
self.set_header('Access-Control-Max-Age', 10)
print('--option--')
def put(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
print('--put--')
self.write('--put--') ***********************************************
--localhost:8888 function corscomplex() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
headers:{'key1':'xxx'},
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
}

控制预检过期时间:

self.set_header('Access-Control-Max-Age', 10)   //10秒

c、跨域传输cookie

在跨域请求中,默认情况下,HTTP Authentication信息,Cookie头以及用户的SSL证书无论在预检请求中或是在实际请求都是不会被发送。

如果想要发送:

  • 浏览器端:XMLHttpRequest的withCredentials为true

  • 服务器端:Access-Control-Allow-Credentials为true

  • 注意:服务器端响应的 Access-Control-Allow-Origin 不能是通配符 *

--localhost:8889

def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Methods', "PUT")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Credentials', "true") //必须
print('--option--')
def put(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Credentials', "true") //必须print(self.cookies)
self.set_cookie('k1','kkk')
self.write('--put--') ***********************************************
--localhost:8888 function corscomplex() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
data:{'v1':'k1'},
xhrFields:{withCredentials: true},
success:function (callback) {
console.log(callback)
}
});
}

d、跨域获取响应头

默认获取到的所有响应头只有基本信息,如果想要获取自定义的响应头,则需要再服务器端设置Access-Control-Expose-Headers。

--localhost:8889

def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Methods', "PUT")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Headers', "key1,key2")
self.set_header('Access-Control-Allow-Credentials', "true")
print('--option--')
def put(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Credentials', "true")
self.set_header('bili', "daobidao") //设置响应头
self.set_header('Access-Control-Expose-Headers', "xxoo,bili") //允许发送
print(self.cookies)
self.set_cookie('k1','kkk')
self.write('--put--') ***********************************************
--localhost:8888 function corsRequest() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
data:{'v1':'k1'},
xhrFields:{withCredentials: true},
success:function (callback,statusText, xmlHttpRequest) {
      console.log(callback);
      console.log(xmlHttpRequest.getAllResponseHeaders());
    }
});
}

示例代码整合:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Welcome !
<p>
<input type="button" onclick="Jsonp1();" value='原生'/>
</p> <button onclick="jsonpclick()" value="button1">button本地</button>
<button onclick="jsonpclickJX()" value="button2">buttonJX</button>
<button onclick="jsonpclickshort()" value="button3">buttonSHort</button>
<button onclick="corsSimple()" value="button4">corsSimple</button>
<button onclick="corscomplex()" value="button5">corsComplex</button>
<button onclick="corscookie()" value="button6">corsCookie</button>
<button onclick="corsRequest()" value="button7">corsRequest</button>
<script src="{{ static_url('jquery-1.8.2.js') }}"></script>
<script>
function Jsonp1(){
var tag = document.createElement('script');
tag.src = 'http://localhost:8889/index';
document.head.appendChild(tag);
document.head.removeChild(tag);
}
function func(arg) {
console.log(arg)
}
function list(arg) {
console.log(arg)
}
function jsonpclick() {
$.ajax({
url:'http://localhost:8889/index',
dataType:'jsonp',
jsonpCallback:'func',
jsonp:'callback',
});
}
function jsonpclickJX() {
$.ajax({
url:'http://www.jxntv.cn/data/jmd-jxtv2.html',
dataType:'jsonp',
jsonpCallBack:'func',
jsonp:'callback',
});
}
function jsonpclickshort() {
$.ajax({
url:'http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list',
dataType:'jsonp',
jsonpCallBack:'func',
});
}
function corsSimple() {
$.ajax({
url:'http://localhost:8889/index',
type:'post',
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
}
function corscomplex() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
headers:{'key1':'xxx'},
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
}
function corscookie() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
headers:{'key1':'xxx'},
xhrFields:{withCredentials: true},
data:{'v1':'k1'},
success:function (callback) {
console.log(callback)
}
});
}
function corsRequest() {
$.ajax({
url:'http://localhost:8889/index',
type:'put',
headers:{'key1':'xxx'},
xhrFields:{withCredentials: true},
data:{'v1':'k1'},
success:function (callback,statusText, xmlHttpRequest) {
console.log(callback);
console.log(xmlHttpRequest.getAllResponseHeaders());
}
});
}
</script>
</body>
</html>

localhost:8888/index.html

import tornado.ioloop
import tornado.web class MainHandler(tornado.web.RequestHandler):
def get(self):
callback = self.get_argument('callback')
print(callback)
self.write("%s([11,22,33,44])"%callback)
def post(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
v1 = self.get_argument('v1')
print(v1)
self.write('--post--')
def options(self, *args, **kwargs):
self.set_header('Access-Control-Allow-Methods', "PUT")
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Headers', "key1,key2")
self.set_header('Access-Control-Allow-Credentials', "true")
print('--option--')
def put(self, *args, **kwargs):
v1 = self.get_argument('v1')
self.set_header('Access-Control-Allow-Origin', "http://localhost:8888")
self.set_header('Access-Control-Allow-Credentials', "true")
print(v1)
print(self.cookies)
self.set_cookie('k1','kkk')
self.set_header('bili', "daobidao")
self.set_header('Access-Control-Expose-Headers', "xxoo,bili")
self.write('--put--') settings = {
'template_path': 'views', # 模版路径的配置
'static_path' : 'static', # 静态文件路径
# 'static_url_prefix' : '/sss/',
} application = tornado.web.Application([
(r"/index", MainHandler),
],**settings) if __name__ == "__main__":
application.listen(8889)
tornado.ioloop.IOLoop.instance().start()

localhost:8889/python

【Python之路】第十七篇--Ajax全套的更多相关文章

  1. Python之路(第十七篇)logging模块

    一.logging模块 (一).日志相关概念 日志是一种可以追踪某些软件运行时所发生事件的方法.软件开发人员可以向他们的代码中调用日志记录相关的方法来表明发生了某些事情.一个事件可以用一个可包含可选变 ...

  2. Python之路(第二十七篇) 面向对象进阶:内置方法、描述符

    一.__call__ 对象后面加括号,触发执行类下面的__call__方法. 创建对象时,对象 = 类名() :而对于 __call__ 方法的执行是由对象后加括号触发的,即:对象() 或者 类()( ...

  3. Python之路【第九篇】:Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy

    Python之路[第九篇]:Python操作 RabbitMQ.Redis.Memcache.SQLAlchemy   Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用 ...

  4. Python之路【第一篇】python基础

    一.python开发 1.开发: 1)高级语言:python .Java .PHP. C#  Go ruby  c++  ===>字节码 2)低级语言:c .汇编 2.语言之间的对比: 1)py ...

  5. 【Python之路】特别篇--抽屉新热榜

    登陆与注册 注册功能: 流程: 填写用户名,邮箱,获取邮箱验证码,填入密码 单击<下一步>按钮,完成注册! 1.获取邮箱验证码(具体步骤分析): 1.利用ajax 往后台传入邮箱, 2.后 ...

  6. 【Python之路】第九篇--Python基础之线程、进程和协程

    进程与线程之间的关系 线程是属于进程的,线程运行在进程空间内,同一进程所产生的线程共享同一内存空间,当进程退出时该进程所产生的线程都会被强制退出并清除.线程可与属于同一进程的其它线程共享进程所拥有的全 ...

  7. 【Python之路】第二篇--初识Python

    Python简介 Python可以应用于众多领域,如:数据分析.组件集成.网络服务.图像处理.数值计算和科学计算等众多领域.目前业内几乎所有大中型互联网企业都在使用Python,如:Youtube.D ...

  8. 学习python之路_入门篇A

    偶尔经同事的介绍进入了金角大王的博客里,看到大王编写的文章都是关于python编程的,由于自己一直也是做软件测试方面的工作,也一直想往自动化测试方面发展,了解到利用python可以进行自动化测试操作, ...

  9. Python之路,第一篇:Python入门与基础

    第一篇:Python入门与基础 1,什么是python? Python 是一个高层次的结合了解释性.编译性.互动性和面向对象的脚本语言. 2,python的特征: (1)易于学习,易于利用: (2)开 ...

随机推荐

  1. CI框架源代码阅读笔记7 配置管理组件 Config.php

    原文见这里:http://www.cnblogs.com/ohmygirl/p/CIRead-7.html 一个灵活可控的应用程序中,必定会存在大量的可控參数(我们称为配置),比如在CI的主配置文件里 ...

  2. 远程调试 Weinre

    什么是远程调试? 说白了,就是可以通过PC端[F12开发者工具]查看并调试移动端的页面内容,如html.css.js.Network资源等. 重要的事情说三遍:weinre所占有的端口不需要和监听页面 ...

  3. 点滴积累【C#】---序列化和反序列化

    序列化和反序列化效果图: 序列化和反序列化代码: 需要添加两个命名空间: using System.IO; using System.Runtime.Serialization.Formatters. ...

  4. atitit.提升研发效率的利器---重型框架与类库的区别与设计原则

    atitit.提升研发效率的利器---重型框架与类库的区别与设计原则 1. 框架的意义---设计的复用 1 1.1. 重型框架就是it界的重武器. 1 2. 框架 VS. 库 可视化图形化 1 2.1 ...

  5. centos 6.5 安装mysql 5.7.21 community

    Step1: 检测系统是否自带安装mysql # yum list installed | grep mysql Step2: 删除系统自带的mysql及其依赖命令: # yum -y remove ...

  6. SQL Server DTS向导,字段转换出现202和200错误

    当使用SQL Server 2012的DTS向导(Import and Export Data/导入导出数据)时,会出现如下问题: 当来源数据直接使用表的时候,没有任何问题 但如果来源数据是查询时,就 ...

  7. IO模型(阻塞、非阻塞、多路复用与异步)

    IO模型 同步IO和异步IO,阻塞IO和非阻塞IO分别是什么,到底有什么区别?不同环境下给出的答案也是不一的.所以先限定一下上下文是非常有必要的. 本文讨论的背景是Linux环境下的network I ...

  8. vim 将tab转为空格

    在vimrc中添加以下选项 set expandtab 会将tab转换为空格,如果要输入一个tab则需要Ctrl-V<Tab>来实现 set tabstop= 会将tab转换为4个空格 使 ...

  9. spring mvc +easy ui +Mybatis 录入数据

    1.itemsEasyui.jsp 应用到的插件及知识点:日期控件My97 ,图片本地预览函数PreviewImage() (1)easy ui 的模态窗口使用时,要指定DIV的属性 data-opt ...

  10. C++设计模式之建造者模式(二)

    3.省略指挥者Director的建造者模式 指挥者类Director在建造者模式中扮演很关键的数据.简单的Director类用于指导详细建造者怎样构建产品,它按一定次序调用Builder的buildP ...