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")
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);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.