JSON cross site without JSONP

后端 未结 5 977
半阙折子戏
半阙折子戏 2021-01-22 15:15

I have a local piece of hardware that I access via it\'s IP address to retrieve json data.

I am creating a web based app but it can not access the local json data when t

5条回答
  •  死守一世寂寞
    2021-01-22 16:05

    You can proxy it with a PHP/ASP/etc. page on your local site that (in the back-end) will query the remote information. This will allow you to call somesite.com/getForeignData (which actually calls othersite.com/foreignData) and return it within the same domain.

    Other than that, you're going to need to use JSONP (this is a boundary purposely set). The "last" option is to enable cross-boundary calls on your browser, but if you want others to have the same ability, this is only a temporary solution.

提交回复
热议问题