Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax calls to subdomain

I have one server located at example.com running apache, serving my static html files.

I also have a json service located at api.example.com running python with cherrypy.

The user requests example.com and get the index html page. On that page I make an ajax request with jquery to the json service. document.domain returns example.com

        $.ajax({
        type: 'GET',
        url: 'http://api.example.com/resource/',
        dataType: 'json',
        success: successCallback,
        error: errorHandler
    });

However, I can't see the response body for the ajax request in firebug. This leads me to believe that the browser (FF) doesn't support this.

What are the best methods to achieve this? I would prefer not to use any proxying on the apache backend for example.com if possible.

like image 242
Baversjo Avatar asked Jun 28 '10 14:06

Baversjo


1 Answers

You can also use JSONP by adding callback=? to the end of the url. jQuery already knows how to handle these type of requests but it does require some server side changes to handle the callback param.

like image 109
Rob Avatar answered Nov 15 '22 13:11

Rob