我想使用Ajax调用,这是我问的 previous问题。它应该不回应任何东西。但每当我把这种阿贾克斯功能,火狐(萤火虫)是显示200确定为红色。这必须是一个跨域的问题。试了太多的东西,但至今没有运气。这里是code:
I am trying to login to my wordpress site using ajax call, which i asked in previous question. It should not respond anything back. But whenever i call this ajax function, Firefox(firebug) is showing 200 OK in red. This must be a cross domain issue. Tried too many things but no luck so far. Here is the code:
$.ajax({ type: "POST", url: "path-to-wordpress/wp-login.php", data:myData success: function(data){ }, error: function (xhr, ajaxOptions, thrownError) { } });
任何建议将AP preciated。
Any suggestion will be appreciated.
推荐答案我假设你的JS code是在 abc 和你的话preSS网站是 dev.abc 。
I assume your JS code is on abc and your wordpress site is dev.abc.
要解决跨域问题,只需添加以下code到的.htaccess 文件到你的话preSS网站(开发.abc )
To fix cross domain issue, just add the following code to .htaccess file to your wordpress site (dev.abc)
SetEnvIf Origin "^http(s)?://(.+\.)?(abc\)$" origin_is=$0 Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
只需更换(ABC \ .COM)有一个适当的站点名称。对于例如:(谷歌\ .COM)或(雅虎\ .COM)
Just replace (abc\) with a proper site name. For eg: (google\) or (yahoo\)
更多推荐
AJAX调用跨域问题
发布评论