Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8531011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:23:11+00:00 2026-06-11T09:23:11+00:00

<html> <head> <script type=text/javascript src=http://code.jquery.com/jquery-1.8.0.js></script> <title> Login page </title> </head> <body> <h1 style=font-family:Comic Sans

  • 0
<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.js"></script>
<title>
Login page
</title>
</head>
<body>
<h1 style="font-family:Comic Sans Ms;text-align"="center";font-size:20pt;
color:#00FF00;>
Simple Login Page
</h1>
<form name="login">
Username<input type="text" name="userid"/>
Password<input type="password" name="pswrd"/>
<input type="button" onclick="check(this.form)" value="Login"/>
<input type="reset" value="Cancel"/>
</form>
<script language="javascript">
function check(form)
{
    $.ajax({
    type: 'POST',
    url: '/auth/login',
    data: { 
        'UserName': form.userid.value, 
        'Password': form.pswrd.value // <-- the $ sign in the parameter name seems unusual, I would avoid it
    },
    success: function(msg){
       console.log(msg);
    }
});
}
</script>
</body>
</html>

Tornado code:
class MainHandler(BaseHandler):
@tornado.web.authenticated
def get(self):
self.render(“index.html”)

class AuthLoginHandler(BaseHandler):
    @tornado.web.asynchronous
    def get(self):
        self.render("login.html")

    def post(self):
        username = self.get_argument("UserName",strip = True)
        password = self.get_argument("Password",strip = True)
        user = auth_actions.do_login(db,username,password)
        if not user:
            raise tornado.web.HTTPError(500, "Authentication Failed")
        self.set_secure_cookie("user", tornado.escape.json_encode(user))
        self.redirect("/")

I send the redirect request and instead of the browser redirecting it just gets the html data of index.html in msg.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:23:13+00:00Added an answer on June 11, 2026 at 9:23 am

    You’re using AJAX to retrieve a page, not a command.

    Imagine you have a webpage open, then you want to get data from another page. You open that page in a new tab, and the server-side tells it to redirect to “/”, so you find yourself at index.html in this second tab, but the first one remains in the same location.

    This is exactly what your AJAX is doing. You’ve told it to get the contents of the page, and when that page sends a redirect order, it just gets the contents of the page the request is redirected to and returns that instead.

    Due to this, AJAX returns a 200 status code for success, instead of a 301 code for a redirect. What would be a better solution, is to have your server reply with unique response, which the browser can recognise and redirect appropriately. An example of this could be to output a simple string, such as redirect, which would never appear on its own in a valid output. The jQuery could then be altered appropriately:

    success: function(msg){
       if (msg=='redirect') {
          //Redirect to the index
       }
       else {
          console.log(msg);
       }
    }
    

    This would redirect if appropriate, or output to the log otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code <html> <head> <script src=jquery-1.7.2.min.js type=text/javascript></script> <script src=jquery-ui-1.8.20.custom.min.js type=text/javascript></script> <script type
#!/usr/bin/perl print Content-type: text/html \n\n; print qq(<html> <head> <script type=text/javascript src=/jquery.js></script> <script> jQuery(document).ready(function(){ jQuery(#form_lang).submit(function(e){
I am runing the following jquery script: <html> <head> <script type=text/javascript src=jquery.js></script> <script type=text/javascript>
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {
<!DOCTYPE html> <html lang=en> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
<META http-equiv=Content-Type content=text/html;> <META content=MSHTML 6.00.2900.3314 name=GENERATOR></HEAD> <?php $current_time=D M j G:i:s; ?> <script
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
Below is my code <script type=text/javascript> var Tag1, Tag2, Tag3, Tag4; var Data1,Data2,Data3,Data4; function
Suppose we have the following HTML file: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test iframe download</title> <script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.