angularjs $http.get 和 $http.post 传递参数
2024-10-10 10:00:19
$http.get请求数据的格式
- $http.get(URL,{
- params: {
- "id":id
- }
- })
- .success(function(response, status, headers, config){
- })
$http.post请求数据的格式
- $http.post(URL,{
- "id":id
- })
- .success(function(response, status, headers, config){
- })
tips:
get 和 post方法传递参数的方式不一样。
- //分享商品 list 列表
- .factory("shareGoodsListService",["$http",function($http){
- return {
- //得到所有的收货地址
- updateAddress : function(__scope__,addrid){
- //获取地址的值
- var Province = $("select[name='Province']").val();
- var City = $("select[name='City']").val();
- var Area = $("select[name='Area']").val();
- var formData = {
- id:addrid,
- name:__scope__.formData.name,
- mobile:__scope__.formData.mobile,
- province:Province,
- city:City,
- area:Area,
- address:__scope__.formData.address,
- zip:__scope__.formData.zip,
- submit:"submit"
- };
- $http.post("{:U('AddressInfo/editAddress')}",formData).success(function(response, status, headers, config){
- if(response.status == 1){
- alert("修改成功!");
- }
- })
- },
- getAddress:function(){
- //$http.get方法 传递参数使用的是 {params:jsonObj}
- $http.get("{:U('AddressInfo/editAddress')}",{
- params: {
- "id":id
- }
- })
- .success(function(response, status, headers, config){
- //获取地址的数据
- if(response.status == 1){
- __scope__.formData = {
- name:response.data.name,
- mobile:response.data.mobile,
- address:response.data.address,
- zip:response.data.zip
- };
- //默认收货地址的值
- new PCAS("Province","City","Area",response.data.province,response.data.city,response.data.area);
- }
- })
- }
- }
- }])
最新文章
- Windows_RTM_RC
- Unity3D使用经验总结 缺点篇
- POJ 2001 Shortest Prefix
- 坚持c++,真正掌握c++(2)
- [转]【基于zxing的编解码实战】精简Barcode Scanner篇
- RTX管理器服务运行状态空白
- HDU 5618 Jam's problem again
- JQuery中html()方法的注意事项
- oracle 选择最频繁出现之前,5文章数据
- ##7.Dashboard web管理界面-- openstack pike
- javaweb重定向的两种方式
- [Swift]LeetCode983. 最低票价 | Minimum Cost For Tickets
- Mysql优化系列(1)--Innodb重要参数优化
- 函数和常用模块【day05】:装饰器高潮(三)
- unity3D iTween的使用
- Linux SSH免登陆配置步骤
- Python第二弹--------类和对象
- golang的bytes.NewReader函数出现的问题
- oracle的字符集设置与乱码
- [Unity]游戏Inside中的Chromatic Aberration效果学习
热门文章
- i春秋-Phone number(union注入+hex转码)
- Android Jetpack 架构组件最佳实践之“网抑云”APP
- SpringSecurity:简单入门
- [C++]-string类的常用操作
- Linux 学习Shell一部分指令
- Windows10 + Chrome 触发蓝屏
- Linux 并发服务器编程(多进程)
- Java中Lambda表达式基础及使用详解
- ffmpeg第2篇:简单滤镜与复杂滤镜的区别
- SpringCache(redis)