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)的更多相关文章

  1. 通过AngularJS实现前端与后台的数据对接(二)——服务(service,$http)篇

    什么是服务? 服务提供了一种能在应用的整个生命周期内保持数据的方法,它能够在控制器之间进行通信,并且能保证数据的一致性. 服务是一个单例对象,在每个应用中只会被实例化一次(被$injector实例化) ...

  2. AngularJs之九(ending......)

    今天继续angularJs,但也是最后一篇关于它的了,基础部分差不多也就这些,后续有机会再写它的提升部分. 今天要写的也是一个基础的选择列表: 一:使用ng-options,数组进行循环. <d ...

  3. AngularJS过滤器filter-保留小数,小数点-$filter

    AngularJS      保留小数 默认是保留3位 固定的套路是 {{deom | number:4}} 意思就是保留小数点 的后四位 在渲染页面的时候 加入这儿个代码 用来精确浮点数,指定小数点 ...

  4. Angular企业级开发(1)-AngularJS简介

    AngularJS介绍 AngularJS是一个功能完善的JavaScript前端框架,同时是基于MVC(Model-View-Controller理念的框架,使用它能够高效的开发桌面web app和 ...

  5. 模拟AngularJS之依赖注入

    一.概述 AngularJS有一经典之处就是依赖注入,对于什么是依赖注入,熟悉spring的同学应该都非常了解了,但,对于前端而言,还是比较新颖的. 依赖注入,简而言之,就是解除硬编码,达到解偶的目的 ...

  6. 步入angularjs directive(指令)--点击按钮加入loading状态

    今天我终于鼓起勇气写自己的博客了,激动与害怕并存,希望大家能多多批评指导,如果能够帮助大家,也希望大家点个赞!! 用angularjs 工作也有段时间了,总体感觉最有挑战性的还是指令,因为没有指令的a ...

  7. 玩转spring boot——结合AngularJs和JDBC

    参考官方例子:http://spring.io/guides/gs/relational-data-access/ 一.项目准备 在建立mysql数据库后新建表“t_order” ; -- ----- ...

  8. 玩转spring boot——结合jQuery和AngularJs

    在上篇的基础上 准备工作: 修改pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=&q ...

  9. 通过AngularJS实现前端与后台的数据对接(一)——预备工作篇

    最近,笔者在做一个项目:使用AngularJS,从而实现前端与后台的数据对接.笔者这是第一次做前端与后台的数据对接的工作,因此遇到了许多问题.笔者在这些问题中,总结了一些如何实现前端与后台的数据对接的 ...

  10. AngularJS 系列 学习笔记 目录篇

    目录: AngularJS 系列 01 - HelloWorld和数据绑定 AngularJS 系列 02 - 模块 (持续更新)

随机推荐

  1. 20145229吴姗珊两天小总结 《Java程序设计》第4周学习总结

    20145229吴姗珊两天小总结 <Java程序设计>第4周学习总结 教材学习内容总结 由于自己的基础不好对知识的理解不透彻,所以这两天的学习还是集中在第六章和第七章,对知识点多了一点理解 ...

  2. 手机端适配rem代码片段

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. django-forms表单验证

    django生成登录随机图片验证码:http://www.cnblogs.com/wupeiqi/articles/4786251.html def insert(request): # print( ...

  4. 剑指offer之 斐波那契数列

    package Problem9; public class Fibonacci { /* * 题目描述: 写一个函数,输入n,求斐波那契数列的第n项,斐波那契数列的定义如下: n=0,f(n)=0 ...

  5. 51nod 1525 && CF566D

    题意:给定n个元素,现在有2种合并操作和1种询问操作 1.单独合并两个元素所在的集合 2.合并一个区间内的元素所在的集合 询问:两个元素是否属于统一集合 神犇题解 感觉又涨了新姿势啊..我们最恼火的是 ...

  6. TCP和UDP?

    简单讲,TCP是打电话,UDP是发短信.

  7. C++的异常捕获

    听课笔记: #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; void fun() { ;// ...

  8. js 格式华货币

    /*货币格式化*/ function formatMoney(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) { nu ...

  9. tomcat警告:Setting property 'source' to 'org.eclipse.jst.j2ee.server:ServletPro' did not find a matching property

    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclips ...

  10. 一个可以拖拽的div

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...