I've never used python before. Thus, I'm kind of confused. I'm trying to use python script to obtain data from the education api. I'm unsure as to how I would accomplish this. I have the following python script:
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
import urllib2
# Create instance of FieldStorage
form = cgi.FieldStorage()
#download data from request parameter 'url'
print "Content-type:text/xml
"
url = form.getvalue("url")
callback = form.getvalue("callback")
req = urllib2.Request(url)
response = urllib2.urlopen(req)
data = response.read()
print callback + "(" + data+ ")"
I know I would replace the url in this text with url of the website I'm requesting the data from. However, what do I replace callback with?
I also understand I will need make a ajax call to retrieve the json data in my browser. How would I do this?
The code I have to return the json is the following:
$.ajax({
url : "getData.py",
data : {url : "http://api.education.com/service/service.php?f=schoolSearch&key=mykey&
sn=sf&v=4&city=Atlanta&state=ga&Resf=json"},
complete : function(xhr, result) {
if (result != "success")
return;
var response = xhr;
console.log(var);