crossdomain - Ajax

久未见 提交于 2019-12-11 09:50:03

问题


I need to call a wordpress page and show the page in a div tag on another webpage not using iframes etc. I have tried many different approaches like jsonp and so on, but i need a good example, keeps getting errors. I have full access to both domains.

Kind regards Mikael


回答1:


Create an .htaccess on the domain you want to access with this:

Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

Then you can use jQuery .load, for example, to get pages from the other domain.



来源:https://stackoverflow.com/questions/7955998/crossdomain-ajax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!