I am developing a web application (for learning purposes) and I am stuck at how to load another page after a particular button is clicked
I am using django 1.4.5 web framework along with python 2.7.4 I have already designed all the html pages and javascript and css files.
I have no idea about HttpRequests. And studying various tutorials i came across these three methods.
1)
xhr = new XMLHttpRequest();
xhr.open("GET","screen2/",false);
xhr.send(null);
2)
location.href="/screen2/"
3)
window.open("/screen2/","_parent");
all of 'em are kept inside the function setup()
,the button's onclick
is set to onclick="setup()"
Yes, I comment them out to keep only one of them "alive" at a time.
django urls.py file:
urlpatterns = patterns('',
url(r'^screen1/$',screen1),
url(r'^screen2/$',screen2),
)
django views.py file
def screen1(request):
f = open(r"mysite/frontend/1st screen.html",'r')
html = f.read()
return HttpResponse(html)
def screen2(request):
f = open(r'mysite/frontend/2nd Screen.html','r')
html = f.read()
return HttpResponse(html)
Second and third methods work the first doesn't. I don't understand why.
Also, How to send the corresponding scripts and css files with the request ?