jQuery中$.ajax()的get 方法
来源:互联网 发布:在英国怎么淘宝购物 编辑:程序博客网 时间:2024/05/16 12:25
这两天在搞跨域的问题,新手一个,就写写自己都遇到什么问题,总结一下吧。
1.用get方法来请求数据
$.ajax({ type: 'GET', url:'http://write.blog.csdn.net', dataType: 'json', success: function( result ) { console.log(result.data.order_list); orderList.lists = result.data.order_list; } });
所遇到的问题:
url的跨域问题,无法访问,最后通过服务器转发解决,但post方法似乎不能用服务器转发,一直报错,求指导~
2.用get方法向服务器返回数据
$.ajax({ type:'GET', url: 'http://write.blog.csdn.net', dataType: 'json', data: { key: '1e9e532fcf27238d4364c2ad36', pre_order_id: orderList.lists[index].pre_order_id, store_address: updata }, success:function(result) { console.log(result) if(result.state === 'success') {orderList.lists[index].store_address = updata; alert("修改成功") }else{ alert("修改失败") } }, error:function() { console.log() alert('服务器走丢了') } })
所犯的错:
success有返回值之后并没有去测试,判断返回值是否正确,就执行了修改语句;
data里面的参数也可以通过键值对的方式添加到url后面进行传参。
逻辑问题,基础知识欠缺。
阅读全文
0 0
- jQuery中$.ajax()的get 方法
- JQuery--Ajax--get方法
- jQuery ajax - get() 方法
- JQuery AJAX $.get()方法
- jQuery ajax - get() 方法
- Jquery中AJAX的get的用法
- 锋利的jQuery读书笔记---jQuery中Ajax--get、post等方法
- JQuery 中的ajax的方法 ($.ajax,$.post.$get,$.jgetJSON)
- jQuery-ajax-.get,.post方法
- Jquery的Ajax中get和post方法的不常见问题
- jQuery中$.get、$.post、$.getJSON、$.ajax 方法详解
- jQuery中$.get、$.post、$.getJSON、$.ajax 方法详解
- jQuery中$.get $.post $.getJSON $.ajax方法详解
- jQuery中$.get、$.post、$.getJSON、$.ajax 方法详解
- JQuery中ajax,get方法在asmx中的使用
- 深入理解JQuery中$.get()、$.post()、$.getJSON()、$.ajax()方法
- jQuery官方文档对Ajax中get和post方法的解释
- jquery的get,post和ajax方法的使用
- java数据结构与算法-简单排序-选择排序
- putback()
- [leetcode]480. Sliding Window Median
- 进程间通信之消息队列
- Java:final关键字 详解
- jQuery中$.ajax()的get 方法
- 免押金渠道上线后产生bug
- hdu1556 Color the ball 线段树
- 回型取数
- groovy 字符串和循环基础
- Git+IDEA
- java数据结构与算法-简单排序-选择排序
- 51nod 动态规划基础篇 6
- Java继承