Is it possible to use the postMessage()
method in Javascript to do cross-domain POST
, GET
, PUT
, etc. calls? If so, how? And how do I pass headers and data?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
This is a two way implementation, meaning that the page you want to call needs to have a callback that listens to such a message and give an appropriate response. You can't simply use it as a swap replacement for AJAX. The best method for that is to use a server-side proxy.
See this page for an explanation of how
postMessage
works.Yes, it is possible.
There is a nice demo of what exactly you want, here
handled on the second side with