ionic项目之上传下载数据

本文介绍了在Ionic项目中进行数据上传和下载的实现方法。在AngularJS的Controller中使用$http服务,通过params参数进行数据上传,服务端通过url解析接收。下载数据时,服务端响应的数据会作为success回调的data返回。注意确保JSON格式正确。在本地调试时,可能遇到跨域问题,可通过修改浏览器启动参数或关闭安全策略解决。项目源码和服务器代码可在指定链接获取。
摘要由CSDN通过智能技术生成

一,首先是上传数据

记得在angularjs的controller中注入$http依赖

var data = {id: $scope.task_id, 
         	groupId: $scope.task_groupid, 
         	importance: $scope.priority_level, 
         	classname:$scope.classname, 
         	title: $scope.task_title, 
         	date: $scope.todo_date, 
         	detail: $scope.task_detail,
         	images:$scope.images_list,
         	name:$scope.name,
         	record:$scope.recordPath,
         	donedate:$scope.done_date}
        
         $http({
         	method: 'POST',
         	url: 'http://localhost:3000',
         	params:{
         		'require': data
         	}
         	
         }).success(function(data,status,headers,config){
         	
         }).error(function(data,status,headers,config){
         	
         });


$http方法中的data参数,服务端没有接收成功

$http方法中的params参数,服务端接收成功

服务端接收方法是 url.parse(req.url, true).query.params

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值