angularJS --$http请求方式
来源:互联网 发布:淘宝特卖女装连衣裙 编辑:程序博客网 时间:2024/05/16 14:03
- 1,GET
- 2,POST
- 3,JSONP
- <!DOCTYPE html>
- <html lang="zh_CN">
- <head>
- <meta charset="UTF-8">
- <title>Angular基础</title>
- </head>
- <body>
- <div ng-app="myApp">
- <div ng-controller="personCtrl">
- 姓:<input type="text" ng-model="firstName"/><br/>
- 名:<input type="text" ng-model="lastName"/><br/>
- 姓名:<span ng-bind="firstName"></span><span ng-bind="lastName"></span>
- </div>
- </div>
- <script src="angular.min.js"></script>
- <script type="application/javascript">
- var myApp=angular.module('myApp',[]);
- myApp.controller('personCtrl',function($scope,$http){
- $http.get('getData.php').
- success(function(data) {
- console.log(data);
- }).
- error(function(err) {
- //错误代码
- });
- //$http.post采用postJSON方式发送数据到后台,
- // 解决办法:在后台php中使用$postData=file_get_contents("php://input",true);这样就可以获得前端传送过来的数据
- var postData={msg:'post的内容'};
- var config={params:{id:'5',name:'张三丰'}};
- $http.post('postData.php', postData,config).
- success(function(data) {
- console.log(data);
- }).
- error(function(err) {
- //错误代码
- });
- var myUrl ="http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1&callback=JSON_CALLBACK";
- $http.jsonp(myUrl).success(
- function(data){
- console.log(data);
- }
- ).error(function(err){
- //错误代码
- });
- $scope.firstName="Wang";
- $scope.lastName="Ben";
- });
- </script>
- </body>
- </html>
0 0
- angularJS --$http请求方式
- $http AngularJS异步请求
- AngularJs $http 请求服务
- AngularJs服务-http请求
- AngularJs $http 请求服务
- AngularJs $http 请求服务
- angularJS的http请求
- angularjs $http请求--图书
- AngularJs $http 请求服务整理
- AngularJS $http模块POST请求
- ajax Http请求方式
- HTTP请求方式总结
- HTTP请求方式
- HTTP请求方式
- http请求方式
- http请求方式
- http请求方式总结
- android http 请求方式
- python2和python3共存
- Android APP反编译之开篇与工具
- js instaneceof
- [经验分享]如何将LPCXpresso的仿真器烧录成CMSIS-DAP或JLINK
- 一步一步搞清排序之归并排序(JAVA)
- angularJS --$http请求方式
- 用yum方式安装软件的优势
- Ubuntu 安装 GNU global
- Java***选择排序***
- 接口回调;new FileFilter(接口)重写accept递归深度遍历后缀名文件;File[]和stringbuffer两种方法
- jstl fn使用
- Windows下路径的获取(未完结)
- 论版本号的正确打开方式
- 关于Java 项目的思考总结