浏览器有一个同源策略,不同的浏览只能读取自己的cookie,所谓同源是指,域名,协议,和端口都必须一样,有一个不一样就会出现
MLHttpRequest cannot load http://www.server.com/server.PHP. No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin 'http://www.client.com' is therefore not allowed access.
对于跨域问题,jsonp的方法,只能接收get方式,对于post方式也是无能为力.
比较舒服的办法就是:服务器允许跨域:在响应头中加上eader信息
<?php //允许所有域名进行访问 header('Access-control-Allow-Origin:*'); //相应类型 header('Access-control-Allow-Methods:Post'); //相应头设置 header('Access-Control-Allow-Headers;x-required-width,content-type'); ?>