views:

584

answers:

1

I have a getJSON call that is called back correctly, but the data variable is null. The python code posted below is executed by the getJSON call to the demandURL. Any ideas?

javascript:

var demandURL = "/demand/washington/";
$.getJSON(demandURL, function(data) {
     console.log(data);
});

python:

data = {"demand_count":"one"}
json = simplejson.dumps(data)
return HttpResponse(json, mimetype="application/json")
A: 

Switch out your getJSON with an ajax call so you can have a look at the error message. Try something like this:

$.ajax({
  url: url,
  dataType: 'json',
  data: data,
  success: function(data) {
    console.log(data);
  },
  error: function(XMLHttpRequest, textStatus, errorThrown) {
    console.log(textStatus, errorThrown);
  }
});
zaius