Search code examples
javascriptjsonjsonpgoogle-hangouts

Calling getJson from hangouts api


Is it possible to use the $.getJSON from a google Hangout Window. I am trying to do it from a barely modified sample version but I can't get any response from the server. http://pastebin.com/x8jXVceQ#


Solution

  • According to the Same origin policy you can just access a document via AJAX, if it is accessed through the same protocol and TCP port and is stored on the same domain.

    If want to access a document from another domain, you can use Cross-origin resource sharing. Therefore the site you want to get via AJAX has to provide the Access-Control-Allow-Origin HTTP header like:

    Access-Control-Allow-Origin: http://hangout.google.com
    

    (You have to replace hangout.google.com with the actual domain of the Google hangout window)