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 8679973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:07:48+00:00 2026-06-12T21:07:48+00:00

i have this Django application in which when user request for localhost:8000/time/ ,it is

  • 0

i have this Django application in which when user request for “localhost:8000/time/ ,it is shown html form input.html.

<head>

<!-- paste this in your footer -->
<script type="text/javascript"> 
$(document).ready(function() {
        $('#myForm').submit(function() { // catch the form's submit event
            $.ajax({ // create an AJAX call...
                data: $(this).serialize(),
                type: $(this).attr('POST'), // "post"
                url: $(this).attr('/poi/'), //  "/poi/"
                success: function(response) { 
                    // do something here
                }
            });
        return false;
    });
});
</script>
<!-- add jquery or it won't work -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</head>

<body>
        <form action="/poi/" method = "post">

        <!---------
        first name :<input type ="text" name ="fname">
        last name:<input type ="text" name ="lname">
        ------>

        enter a days :<input type ="text" name ="days">
        <br>
        <input type=submit name="submit" onclick="submit_function(); return false;">
        </form>

</body>

when form is submitted user sees response.html page and URL is changed to “localhost:8000/poi/ is shown having

urls.py

urlpatterns = patterns('',
                            (r'^hello/$', hello),   
                            ('^time/$', current_datetime),
                            ('^poi/$', next_datetime),

                        )

views.py

def current_datetime(request):  
    return render_to_response('input.html')


def next_datetime(request):

    now = datetime.datetime.now()
    now_day = now.day
    now_month = now.month
    now_year = now.year

    return render_to_response('response.html', {'now_day': now_day, 'now_month'}}

now i have to do same thing but the url should not change from “localhost:8000/time/ to “localhost:8000/poi/
but it should be “localhost:8000/time/

how to accomplish that?

  • 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-12T21:07:49+00:00Added an answer on June 12, 2026 at 9:07 pm

    You have to use ajax to accomplish this
    With jquery it would look something like

    <form id="myForm"> ... </form> <!-- add an id to your form -->
    
    <!-- paste this in your footer -->
    <script type="text/javascript"> 
    $(document).ready(function() {
            $('#myForm').submit(function() { // catch the form's submit event
                $.ajax({ // create an AJAX call...
                    data: $(this).serialize(),
                    type: $(this).attr('method'), // "post"
                    url: $(this).attr('action'), //  "/poi/"
                    success: function(response) { 
                        // do something here
                    }
                });
            return false;
        });
    });
    </script>
    <!-- add jquery or it won't work -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    

    and it should work out of the box

    this is with an anonymous function, but you can put the code inside a named one and then add it to the button:

    <input type="submit" onclick="submit_function(); return false;" />
    

    it’s basically the same

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

Sidebar

Related Questions

I have a user registration form in my Django application which collects additional data
I have a Django application which takes the lat/lon from a user's coordinates via
I have inherited a large Django application and it features this idiom in the
I have this urls on urls.py url(r'^login/$', 'django.contrib.auth.views.login', {'template_name':'login.html'}), url(r'^(one|two)/logout/$', 'django.contrib.auth.views.logout_then_login', {'login_url':'/login/'}) I'm trying
I have a django project which is laid out like this... myproject apps media
I have a web application which will return a user id based on the
I have a form MyForm which I update using ajax as the user fills
I have a view my Django application which when invoked calls my backend. My
I want to have RSS feeds in my Django application, which should be viewable
I have a Django application which allows different kinds of users: firms, administrators, external

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.