jQuery_Ajax

jQuery_Ajaxajax

 

原生Ajax的步骤:服务器

Xhr->xhr.open(get,url)->xhr.send->xhr.onrealystatechange函数

 

jQuery_Ajax:post

语法:url

$.get(url).then(function(res){获取内容执行的函数})ci

$.post(url).then(function(res){获取内容执行的函数})get

 

不分方法:it

$.ajax({io

url:"服务器地址",console

method:"请求方法",

data:{//传给服务器的参数

location:$("#city").val(),

key:'c8b18212397748599a7fb0bfa1022b56'

},success:function(res){//成功执行的函数

console.log("成功的执行:")

console.log(res)

},

fail:function(res){//失败执行的函数

console.log("失败的执行:")

console.log(res)

},

complete:function(res){//无论成功失败都会执行的函数

console.log("complete的执行:")

console.log(res)

}

})

})

相关文章
相关标签/搜索