0

I've searched and searched for an answer to this seemingly simple question, but I just can't find ANYTHING that relates to my question.

What I'm trying to do is use some data that I get as a $.get response in JSONP form in an AJAX request. No matter what I do, the variable doesn't show up in the request!

Here is my GET request:

$.get("http://ip-api.com/json/", function (response) {
    city = (isNull(response.city))?(response.city+","):"";
    state = (isNull(response.state))?(response.state):"";
    location = city + ' ' + state;
    country = response.country;
}, "jsonp");

AJAX request, ignore the asterisks:

$.ajax({
        cache: false,
        data: $.extend({
            publisher: '*****************',
            v: '2',
            format: 'json',
            q: data,
            l: location,
            radius: 50,
            limit:limit,
            sort: 'date',
            highlight: 1,
            filter: 1,
            latlong: 1,
            co: 'au',
            userip: '',
            useragent: ''
        }, { start: start, end: end }),
        dataType: 'jsonp',
        type: 'GET',
        timeout: 5000,
        url: 'http://api.indeed.com/ads/apisearch'
    })

The first request fires on page load and stores the response in variables as shown. I can see in my console inspector that the variables store the correct information. The problem comes when I try to use the information. I run a function that uses the ajax request and the string variables don't show up in the query.

0 Answers0