Hi, I have a post request that is going through, on my app, https://github.com/derekriemer/derek-django My app gets the users location and then makes a post request to the server on pythonanywhere, but it seems that it isn't working. It works perfectly fine on my machine, reloading the view when the weather data comes in for python with manage.py runserver, however, Is there a caveat with pythonanywhere and post requests? It seems that the post request doesn't even go through. my javascript looks like this if it is of any help.
var csrftoken = $.cookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
$.post("forecast",
{
lat : position.coords.latitude,
lng : position.coords.longitude,
page: page
},
function(data, status){
document.write(data);
alert(data+"\n\n"+status);
setTimeout(function(){
document.getElementById("skip").setFocus();
}, 30);;
});
});