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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:15:35+00:00 2026-05-30T10:15:35+00:00

I have a simple form to submit and test ajax,but it doesn’t work and

  • 0

I have a simple form to submit and test ajax,but it doesn’t work and I see any problem in it,I searched alot and there was no more poin-at least I dedn’t see 😉

in urls.py

(r'^doctors/shahsavand/visiting/$','DrHub.views.visiting'),
(r'^doctors/shahsavand/visiting/add/$','DrHub.views.ajxTest')

the first URL is to direct to main page and there’s this form in main page:

<form method='POST' action=".">
        {% csrf_token %}
        <ul>
            <li>
                <label for="start">Start Time: </label><input name="id_startTime" id="id_startTime" type="text" />          
            </li>
            <li>
                <label for="end">End Time: </label><input name="id_endTime" id="id_endTime" type="text" />
            </li>
        </ul>
        <input type="submit" id="save_button" name="save_button" value="add" />
</form>

and ajax code in this page:

<script type='text/javascript' src='/static/DrHub/doctors/shahsavand/js/jquery-1.4.1.js'></script>
<script type="text/javascript">
    $.ajax({
                 type:"POST",
                 url:"{% url DrHub.views.ajxTest %}",
                 data: {
                        'start': $('#id_startTime').val(),
                        'end': $('#id_endTime').val(),
                        'csrfmiddlewaretoken':$( "#csrfmiddlewaretoken" ).val()
                 },
                 success: function(data){
                     alert(data);
                 }
    });
</script>

in views.py :

def ajxTest(request):
    if request.is_ajax():
          if request.method == 'POST':
             return HttpResponse(simplejson.dumps({'message' : 'awesome'}),  mimetype='application/javascript')
    else:
          return render_to_response('DrHub/doctors/nutrition/test.html', context_instance=RequestContext(request))

I did this to test if ajxTest view is called:

def ajxTest(request):
   if request.is_ajax():
      raise Http404
   else:
      pass

and this :

def ajxTest(request):
       if request.is_ajax():
          raise pass
       else:
          Http404

but no result and that sounds like my ajax POST is not associated with ajxTest view !!!

edit

when I check firebug I get 403 forbidden error that is for CSRF and I’ve tryed many things to solve it again no result 🙁

  • 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-05-30T10:15:37+00:00Added an answer on May 30, 2026 at 10:15 am

    Add the javascript described in the documentation for csrf and it should fix your problem.

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

Sidebar

Related Questions

I have a simple form on a page and I want to auto submit
I have a simple web app: a web page with a form to submit,
I have an HTML page with a simple form. When the user clicks submit,
Have a simple form (only extract fields here) but for some reason the JQserilization
I have made a simple plugin with a form but it won't post when
Okay, this should be really simple, but I have searched all over for the
i have this simple html form: <form action=test/ method=get accept-charset=utf-8> <input type=text name=first value=
i have this simple html form: <form action=test/ method=get accept-charset=utf-8> <input type=text name=first value=
I have a simple ajax form and I'm trying to validate that it has
I have a simple form: function mymodule_test_form(&$form_state, $nid) { form['submit'] = array( '#type' =>

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.