0

I need to make a client side http request to receive a string. I am struggling to find a method that works on the client.

I found WebClient.Get. But this one only works on the server. Threading it through opa's client/server communication is not an option because I need this to work, even if the server is down.

Martin Lütke
  • 722
  • 7
  • 11

1 Answers1

0

Browsers do not allow cross domain requests for security reason. See http://en.wikipedia.org/wiki/Same_origin_policy

Something is planned in HTML5 to overcome this (and beta versions of Chrome have net client support), but currently you need to use server-side functions. Hopefully, it's easy to do with Opa.

Henri
  • 214
  • 2
  • 9
Fred
  • 1,092
  • 5
  • 9
  • Actually that is possible with jsonp and jquery has support for this. Also, my http request would be same domain. Its not a question of protocol/policy but rather, and in a broader sense: How to execute custom javascript on the client via opa? That is a different question but its answer would provide me with a workaround. – Martin Lütke Jul 04 '12 at 10:22
  • To force the execution of code on the client side, use "client" directive (http://doc.opalang.org/manual/Developing-for-the-web/Client-server-distribution). – Cédrics Jul 05 '12 at 10:20
  • To use existing js, create a plugin ( http://blog.opalang.org/2012/01/reusing-javascript-libraries-jquery-ui.html) – Cédrics Jul 05 '12 at 10:23