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");
    }
});
6
  • 1
    I think you are looking something like that stackoverflow.com/questions/7544160/… Commented Mar 7, 2014 at 21:34
  • 1
    @Pavlo Doesn't look like it. The OP is making a cross-domain request; that seems to be the problem Commented Mar 7, 2014 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? Commented Mar 7, 2014 at 22:01
  • python is not bound by the Same Origin Policy that JS is... Commented Mar 7, 2014 at 22:02
  • For a work around, I just used my server as proxy for the ajax call. Commented Mar 7, 2014 at 22:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.