• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

jQuery in Action: Can I use jQuery to go across domains

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We had a situation where we wanted to access an application
via https, on another domain.

Does jQuery in Action deal with this possibility?

Thanks,
Mike
 
author
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't do it 'just' with jQuery - BUT here is an easy solution. You can use YQL (web service from yahoo) with jQuery to get just that.
Here is a simple example code that will do the magic for you:


It was posted here:
http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-cross-domain-ajax-request-with-yql-and-jquery/
and you get there a good short video that explain it as well.

Good luck.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might also check out jQuery's ability to use JSONP via Ajax.
 
Ido Green
author
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True.
Here is a simple example for that:

Once the URL includes the string "callback=?" in the URL, the request is treated as JSONP instead.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do I understand correctly that with the cross-domain requests via AJAX with jQuery it's not possible to provide a handler for error conditions, e.g. when that other server is down.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Evguenia Krylova wrote:Do I understand correctly that with the cross-domain requests via AJAX with jQuery it's not possible to provide a handler for error conditions, e.g. when that other server is down.



JavaScript has a same origin policy. jQuery is JavaScript so it does not have any magical powers as some people think it has. Only way to be 100% sure that the server is up is to use your wonderful server to test the connection. Using a proxy on your end to access the other domain may be your best bet. JSONP is great, but limited.

Eric
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic