I'm trying to pass the parameters defined by a user in the front end to a python script being run on the server. I'm using a Django framework in the back end (probably too heavy for my purposes at the moment but wanted to give it a try). Here's the jQuery code I'm using to call the python fxn which is located at the defined url. The parameters I'd like to pass are in the data attribute.
bbviz.onStart = (function() {
$.ajax({
type:'get',
url:'http://localhost:8000/statview/simulation/',
data:{url:'blackch02', 'profile':'current', 'sims':1000},
async:'asynchronous',
dataType:'json',
success: function(data) {
console.log(data);
},
error: function(error) {
console.log(error);
}
});
});
And here's the Django view function:
def simulation(request):
out = batterSim.sim_season(url, profile, sims)
return out
I'm calling the batterSim module and running the sim_season function which has the same named parameters as the data attribute. The function then returns a json object that the front end would receive. So I'm trying to figure out how to take those parameters from the ajax function and use them in the python function.