本文介绍了AJAX,子域和200 OK响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 一个非假设但抽象的情况:A non-hypothetical but abstracted situation:我有一个域名www.foo.com,我从这个域名发送一个AJAX POST到beta.foo。 com。检查XHR对象,我看到一个响应头200 OK,但没有响应文本 - 我甚至得到响应12B长,这是我所期望的确切响应(一个12个字符的字符串) - 但响应文本是空白。I have a domain www.foo.com, from which I'm making an AJAX POST to beta.foo.com. Examining the XHR object, I see a response header of 200 OK, but no response text - I even get a response 12B long, which is the exact response (a 12-character string) that I'm expecting - but the response text is blank.如果这是一个跨域问题,为什么我得到200确定,更好 - 为什么我看到PHP函数在beta.fooIf this is a cross-domain issue, why am I getting 200 OK, and better yet - why am I seeing the PHP functions fire on the beta.foo.com side - yet getting no response?推荐答案你不能做交叉子域名ajax调用那么容易。有一些名为同源政策阻止您这样做的内容。如果您想排序此问题,您需要使用 JSONP 或 Iframes 。You can't do cross subdomains ajax calls that easy. There is something called Same origin policy that prevents you from doing that. If you want sort this issue you need to use JSONP or Iframes.安装firebug,您会看到http 200代码和错误:该错误是SOP行为。Install firebug and you will see an http 200 code and an error: that error is SOP acting. 这篇关于AJAX,子域和200 OK响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-22 20:08