cross domain rest dojo call

爷,独闯天下 提交于 2019-12-13 08:35:53

问题


I have to load data for a different url the page will run on the android browser and will load content from remote server . I have to use dojo so I tried with dojo.xhrGet , it does'nt load the data so when I red the reference guide I saw that that method has some limitation with external url's . So what I have to do now if I have to call a REST service with dojo . the REST service URL on the remote server:

http://192.168.1.65:9080/RAD8JAX-RSWeb/jaxrs/customers/accounts/111-11-1111/

and the data that I should see

[{"id":"001-111001","balance":12345.67},{"id":"001-111002","balance":6543.21},{"id":"001-111003","balance":98.76}]

please help me with a method that can fix my problem I dont know dojo well I'm blocked right now because I can't use the data between two application they can't communicate


回答1:


Your question is unclear, but I think you are saying you want to load data from a different domain to the main web page.

You cannot reliably use AJAX to load data from anywhere other than the domain of page you are visiting. Almost all modern internet browsers deliberately block that, for the protection of their own users.

Instead, you will need to find some way of getting your server to relay the information.

So imagine currently you do:

  • Load page a.example.com/index.html
  • Page uses dojo to try to load b.example.com/data

You would instead need to do:

  • Load page a.example.com/index.html
  • Page uses dojo to try to load a.example.com/data
  • When the a.example.com server receives a request to load /data, it should connect (perhaps using cURL) to b.example.com/data and then output the same text.


来源:https://stackoverflow.com/questions/9549972/cross-domain-rest-dojo-call

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