Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

json - cross domain rest dojo call

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...