Passing a JSON variable from one .getJSON request to another

I’m trying to pass the “yourip” variable from one getJSON request into another to embed it inside the URL of the second JSON request. If I attempt to use a window.alert in the first request, it prints the IP, but when I try to use a window.alert in the second JSON request, it prints undefined. I guess I need to define a global variable but i’m not very experienced with JSON. Any help is appreciated.

Website keeps trying to execute the code and the preformatted text tool requires indentation of each line, so here is a pastebin of the code.