跨域访问JSONP CORS_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:15:52
Original
893 people have browsed it

一、JSONP

常用的Jquery框架支持jsonp方式请求,该方式只支持GET方法,传参大小有限,而且需要后台根据jsonp的请求方式进行封装结果返回。

其中参数jsonp默认为callback,jsonpCallback为随机生成的回调函数名,若指定handleRequest,则后台参数返回时为handleRequest("data")。

 

二、CORS

跨域资源共享CORS方式通过自定义HTTP头部来使浏览器和服务器互相了解对方。

服务器端对CORS的支持主要是设置相应的头部进行支持的:

Access-Control-Allow-Origin: *

Access-Control-Allow-Methods: GET,POST

Access-Control-Request-Headers:Origin,X-Requested-With,Content-Type,Accept

Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!