Reputation: 4158
I've been trying to figure out how to use ajax with the pyramid framework by trying to call a method in my view.py
file. Somewhat new to python so I think I've probably made a mistake with my url in my ajax call since it can't seem to find the file I'm pointing to(maybe too much ASP
influence).
Here is my ajax call:
$.ajax({
url: "../views.py/new_sheet", <---trouble with this
type: "post",
data: {},
dataType: 'text',
success: function(response, textStatus, jqXHR) {
alert("Yay!");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus, errorThrown);
}
});
and this is the method I am trying to call:
@view_config(route_name="test", renderer='templates/main.html')
def new_sheet(self,request):
test = "hello"
return dict(test=test)
any suggestions would be appreciated
Upvotes: 0
Views: 386
Reputation: 2641
You have to specify the URL you want to call, e.g. http:://localhost:8080/myapp/test (since you configuerd to map test to the view)
What you do is trying to call the python function directly from your browser, which is not possible,
Upvotes: 1