AJAX调用跨域问题

编程入门 行业动态 更新时间:2024-10-11 21:24:52
本文介绍了AJAX调用跨域问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用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调用跨域问题

本文发布于:2023-11-28 12:48:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642468.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AJAX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!