3

I am trying to make a ajax call with Jquery to retrieve json data from a website. I can not get it to work in Jquery but I was able to make it work using the python Requests Library. How can I get the ajax data using jquery?

This code works and gets me the data I want (However, I want it client side not server side)

import requests
request = requests.get('http://volaris.com/locations/json/autocomplete/?term=tij&where=&loc=&lang=en')

This code does not. This is the code I would like to work. As of now, it only hits the fail function.

$.ajax({
    url: 'http://volaris.com/locations/json/autocomplete/?term=tij&where=&loc=&lang=en',
    type: 'GET',
    daType: 'json',
    cache: true,
    error: function() {
        alert( "ajax error" );
    },
    success: function(json) {
        alert( "ajax success");
    }
});
fat fantasma
  • 7,483
  • 15
  • 48
  • 66
  • 1
    I think you are looking something like that http://stackoverflow.com/questions/7544160/how-to-send-parameters-with-jquery-get – Pavlo Mar 07 '14 at 21:34
  • 1
    @Pavlo Doesn't look like it. The OP is making a cross-domain request; that seems to be the problem – Ian Mar 07 '14 at 21:38
  • I corrected some typos in my question. Nothing big. XDR seems to be the problem from what I have read but I don't know enough about it. Wouldn't the python request library be an XDR request also and have the same problem? – fat fantasma Mar 07 '14 at 22:01
  • python is not bound by the Same Origin Policy that JS is... – dandavis Mar 07 '14 at 22:02
  • For a work around, I just used my server as proxy for the ajax call. – fat fantasma Mar 07 '14 at 22:34
  • Similar question: [CORS error with Javascript but not with Python/PHP](http://stackoverflow.com/questions/40134558/cors-error-with-javascript-but-not-with-python-php) – user2314737 Jan 27 '17 at 11:05

0 Answers0