4 Replies - 1871 Views - Last Post: 28 June 2013 - 08:21 PM

#1 NoRemorse   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 26-January 11

Question: Cross-domain requests with Jquery or Javascript or smt else

Posted 27 June 2013 - 03:02 AM

So I need to send a request to this site with parameters:

http://localhost:8983/solr/collecion2/update/json?commit=true -d'{'Link': 'http:www.bla.ee'}' -H 'Content-type:application/json'


From this site:

http://localhost:9000/


What would be the easiest/smartest/doable way to achieve this in Jquery/Javascript/Some other framework?

This post has been edited by NoRemorse: 27 June 2013 - 03:03 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Question: Cross-domain requests with Jquery or Javascript or smt else

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Question: Cross-domain requests with Jquery or Javascript or smt else

Posted 27 June 2013 - 03:27 AM

Hey.

I am not aware of any decent way to send POST requests across domains. Not a well supported one, at least. You could look into using the Access-Control-Allow-Origin header, but support for that isn't great yet. At least not if you want to support older browsers, like IE7. - The Wikipedia article on the subject explains the basics pretty well: Cross-origin resource sharing.

If you can incorporate the POST data into the query string, that would simplify matters. <iframe> and <script> elements can be used to send requests to other domains in a pretty consistent manner, so that would be relatively easy.
Was This Post Helpful? 0
  • +
  • -

#3 laytonsdad   User is offline

  • I identify as an attack helicopter!
  • member icon

Reputation: 467
  • View blog
  • Posts: 1,998
  • Joined: 30-April 10

Re: Question: Cross-domain requests with Jquery or Javascript or smt else

Posted 27 June 2013 - 11:28 AM

Why can't you use Ajax to do this?
Was This Post Helpful? 0
  • +
  • -

#4 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Question: Cross-domain requests with Jquery or Javascript or smt else

Posted 28 June 2013 - 07:41 PM

View Postlaytonsdad, on 27 June 2013 - 06:28 PM, said:

Why can't you use Ajax to do this?

Security reasons. The browsers don't allow AJAX requests to 3rd party domains, only the domain from which the main page was requests.

That is, unless you use the Access-Control header I mentioned before, in a browser that supports it.
Was This Post Helpful? 1
  • +
  • -

#5 laytonsdad   User is offline

  • I identify as an attack helicopter!
  • member icon

Reputation: 467
  • View blog
  • Posts: 1,998
  • Joined: 30-April 10

Re: Question: Cross-domain requests with Jquery or Javascript or smt else

Posted 28 June 2013 - 08:21 PM

Atli Thank you, I didn't know this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1