PingPlusPlus / pingpp-php

MIT License
378 stars 182 forks source link

ping-html-one与ping-php的页面必须放在一个server上吗? #26

Closed wonleing closed 8 years ago

wonleing commented 8 years ago

分别放在两个server上会报json decode error, network error

samurai00 commented 8 years ago

跨域了,你需要在服务端加跨域头 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS

wonleing commented 8 years ago

查到了这样的描述 var invocation = new XMLHttpRequest(); var url = 'http://bar.other/resources/public-data/'; function callOtherDomain() { if(invocation) {
invocation.open('GET', url, true); invocation.onreadystatechange = handler; invocation.send(); } }

请明示如何加到client端?

samurai00 commented 8 years ago

你在服务端这个接口的 response header 里加这个就好了

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS