I have a snippet of code such as:
$.getJSON("http://mysite.org/polls/saveLanguageTest?url=" + escape(window.location.href) + "&callback=?",
function (data) {
var serverResponse = data.result;
console.log(serverResponse);
alert(serverResponse);
});
It works fine in the sense that it makes a cross-domain request to my server and the server saves the data as I expect. Unfortunately, even though the server saves data and sends back a response I just can't get any alert or the console.log run. Why may be that? The server side code is (if that is relevant):
def saveLanguageTest(request):
callback = request.GET.get('callback', '')
person = Person(firstName = 'Anonymous',
ipAddress = request.META['REMOTE_ADDR'])
person.save()
webPage = WebPage(url = request.GET.get('url'))
webPage.save()
langTest = LanguageTest(type = 'prepositionTest')
langTest.person = person
langTest.webPage = webPage
langTest.save()
req ['result'] = 'Your test is saved.'
response = json.dumps(req)
response = callback + '(' + response + ');'
return HttpResponse(response, mimetype = "application/json")
What am I missing? (I tried the same code both within my web pages and inside the Firebug and I always have the problem stated above.)