ajax-异步对象接收数据

1.
$ob加载数据
$ob.load(url,data,function(d,status){ })


2.
$.get(url,data,callback,type)

3.
$.post(url,data,callback,type)

实例:
$.post('/demo02', data,
function (d) {
console.log(d)
$('#tip').text(d)
},
'json')


4.$.ajax({})


实例:
$.ajax({url: '/demo02',
type: 'post',
data: data,
dataType: 'json',
success: function (d) {
$('#tip').text(d)
console.log(d)
}
})


jquery 的跨域
代码:
$.ajax({
url:'xxx',
type:'get',
dataType:'jsonp',//指定为跨域访问
jsonp:'callback',//定义了了callback的参数名,以便便获取callback传递过去的函数名
jsonpCallback:'xxx' //定义jsonp的回调函数名
});

猜你喜欢

转载自www.cnblogs.com/chenlulu1122/p/11888927.html