How to make a JSONP POST request in angular?

前端 未结 1 685
终归单人心
终归单人心 2021-01-04 01:30

The $http.jsonp method described in the official documentation seems to always perform get requests: http://docs.angularjs.org/api/ng.$http#methods_jsonp.

I have tri

相关标签:
1条回答
  • 2021-01-04 01:50

    You cannot make a POST request using JSON-P (with or without Angular)

    A JSON-P request works by generating a <script> element with a src attribute. This will always trigger a GET request.


    If you want to make a cross-domain POST request with JavaScript then you must use either XMLHttpRequest (and have the server supply suitable access control headers as per the CORS specification) or proxy the request through the server hosting the page.

    0 讨论(0)
提交回复
热议问题