AngularJs(Part 6)
Overcomming same-origin policy restrictions with JSONP.
AJAX has a restriction that it can only retrieve data from the same resource.
There are several techniques for accessing dta exposed by external servers:JSONP and CORS.
AngularJS contains API that uses JSONP to get data from foreign server.
$http.jsonp(url,config);
the url must contain the JSON_CALLBACK request parameter. that is the URL must be like
xxxx?callback=JSON_CALLBACK
Check out CORS, another way to overcome same-origin policy restrictions
CORS is a W3C specification that aims at solving the same problem as JSONP does , only in a
more standard,reliable , and secure way.
The CORS specificatoin builds on top of the XMLHttpRequest object ot enable the cross-domain AJAX
requests.
CORS requests are roughly divided into "simple" and "non-simple" ones. GET ,POST,HEAD requests
are considered as "simple".
With non-simple requests , the browser is oblisged to send a probing OPTIONS request and wait for the
server's approval before issuing the primary request. So the server must be well-configured for handling
the OPTIONS request.
But, there is also another way to approach the cross-domain request. that is use a local server as
a proxy to a foreign one.
for example, back-end is written by JAVA. then i can get foreign data through JAVA, and then send it
to font-end when requested.
AngularJs(Part 6)的更多相关文章
- 通过AngularJS实现前端与后台的数据对接(二)——服务(service,$http)篇
什么是服务? 服务提供了一种能在应用的整个生命周期内保持数据的方法,它能够在控制器之间进行通信,并且能保证数据的一致性. 服务是一个单例对象,在每个应用中只会被实例化一次(被$injector实例化) ...
- AngularJs之九(ending......)
今天继续angularJs,但也是最后一篇关于它的了,基础部分差不多也就这些,后续有机会再写它的提升部分. 今天要写的也是一个基础的选择列表: 一:使用ng-options,数组进行循环. <d ...
- AngularJS过滤器filter-保留小数,小数点-$filter
AngularJS 保留小数 默认是保留3位 固定的套路是 {{deom | number:4}} 意思就是保留小数点 的后四位 在渲染页面的时候 加入这儿个代码 用来精确浮点数,指定小数点 ...
- Angular企业级开发(1)-AngularJS简介
AngularJS介绍 AngularJS是一个功能完善的JavaScript前端框架,同时是基于MVC(Model-View-Controller理念的框架,使用它能够高效的开发桌面web app和 ...
- 模拟AngularJS之依赖注入
一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...
- 步入angularjs directive(指令)--点击按钮加入loading状态
今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...
- 玩转spring boot——结合AngularJs和JDBC
参考官方例子:http://spring.io/guides/gs/relational-data-access/ 一.项目准备 在建立mysql数据库后新建表“t_order” ; -- ----- ...
- 玩转spring boot——结合jQuery和AngularJs
在上篇的基础上 准备工作: 修改pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&q ...
- 通过AngularJS实现前端与后台的数据对接(一)——预备工作篇
最近,笔者在做一个项目:使用AngularJS,从而实现前端与后台的数据对接.笔者这是第一次做前端与后台的数据对接的工作,因此遇到了许多问题.笔者在这些问题中,总结了一些如何实现前端与后台的数据对接的 ...
- AngularJS 系列 学习笔记 目录篇
目录: AngularJS 系列 01 - HelloWorld和数据绑定 AngularJS 系列 02 - 模块 (持续更新)
随机推荐
- eclipse新建Maven项目
1.在eclipse中安装maven插件 2.点击File->new->maven project,出现弹窗后点击next. 接着在弹窗Select an Archetype中,filte ...
- 【leetcode刷题笔记】Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- vue-router原理分析
本文整理总结自: https://zhuanlan.zhihu.com/p/27588422 单页面应用(SPA)的核心之一是: 更新视图而不重新请求页面, 实现这一点主要是两种方式: 1.Hash: ...
- fzu 1476 矩形个数
注意点:精度 #include<iostream> using namespace std; typedef long long ll; int main() { int a,b; ll ...
- 算法(Algorithms)第4版 练习 1.3.37
package com.qiusongde.creative; import com.qiusongde.Queue; import edu.princeton.cs.algs4.StdOut; pu ...
- 介绍几款Web服务器性能压力测试工具
一.http_load 程序非常小,解压后也不到100K http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载. 但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般 ...
- SDN关键技术-Segment Routing协议简介
当前,SDN作为一种新的网络架构,已经成为行业高度关注的热点.其倡导的开放式网络,代表了从网络应用适应网络能力向网络能力主动适配网络应用需求这个网络建设理念的改变.转发与控制分离.集中的控制层面.开放 ...
- Jackson的用法实例分析
这篇文章主要介绍了Jackson的用法实例分析,用于处理Java的json格式数据非常实用,需要的朋友可以参考下 通俗的来说,Jackson是一个 Java 用来处理 JSON 格式数据的类库,其性能 ...
- $().bind()的返回值
var eleMenus = $("#choMenu a").bind("click", function (event){}); 此时eleMeuns的值是$ ...
- 双系统重装win7和ubuntu修复win7引导方法介绍(来源百度经验)
很多朋友喜欢为电脑安装win7和ubuntu双系统,当我们重装双系统时,可能会出现win7引导不见的情况,接下来就告诉大家双系统重装win7和ubuntu修复win7引导的方法. 1.win7和ubu ...