ajax 跨域问题

1.jquery ajax自己常用写法如下:

$.post(url,data,function(data){
    //data为返回的数据
});
$.post写法
1 $.get(url,data,function(data){
2     //与post相同,只是传输方式不同
3 });
$.get写法
 1 $.ajax({
 2     type: 'get',//or post
 3     url: 'http://xxxx',
 4     data:'',//这里可以写$('form').serialize();序列化表单  or  json 串
 5     dataType:'json',
 6     success: function(data){
 7         //success之后操作
 8     },
 9     error:function(){
10         //error操作
11     }
12 });
$.ajax写法

2.ajax跨域问题

(1).用get方式

(2).传json串

(3).在被请求页面需要添加allow代码,允许ajax请求

posted @ 2015-05-22 17:51  雷林007  阅读(117)  评论(0编辑  收藏  举报