On Thursday, May 3, 2012 11:25:01 PM UTC-4, Madu wrote:
>
> Sorry for this basic question but I don't why the hyperlink is not working:
> <a href="{{redirect(URL('DBInsert'))}}">New DB Insert</a>
>
Note, redirect('some_url') is equivalent to raise HTTP(303,
Location='some_url'). So, when redirect() is called, you are raising an
exception, which immediately aborts the current request and proceeds to
send a redirect response to the browser. Since you call redirect() in your
view, when web2py renders the view, it will immediately issue the redirect
response upon executing that line in the view. See
http://web2py.com/books/default/chapter/29/4#HTTP-and-redirect.
In HTML, the anchor tag simply takes a plain URL as the href attribute.
When the user clicks the link, they are not being "redirected" -- they are
merely requesting a web page. A "redirect" is an instruction returned by
the server to the browser (i.e., a 30x response) telling the browser to
request a different URL instead of the URL originally requested. In this
case, you just want:
<a href="{{=URL('yourcontroller', 'DBInsert'))}}">New DB Insert</a>
Anthony