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

  • Home
  • SEARCH
  • 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 8907535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:56:32+00:00 2026-06-15T02:56:32+00:00

I’ve tried everything here , and I must be missing something, as my ajax

  • 0

I’ve tried everything here, and I must be missing something, as my ajax post to Django isn’t returning anything. I’ve got it down to the bare bones at this point, just trying to get it working and no joy.

My view:

def saveProjectEntry(request):
    form = ProjectEntryUpdateForm(request.POST)

    if form.is_valid():
        msg = json.dumps({'msg':'success'})
        return HttpResponse(msg, mimetype='application/json')
    else:
        msg = json.dumps({'msg':'failed'})
        return HttpResponse(msg, mimetype='application/json')

My url.py entry:

    url(r'^chargeback/savepe/$','chargeback.views.saveProjectEntry'),

My jQuery:

    $('#peUpdateForm').submit(function() {
         $.ajax({
          url:'/chargeback/savepe/',
          data: $("#peUpdateForm").serialize(),
          type: "POST",
          success: function(e) {
              alert("success");
          },
          error: function(e) {
              alert("failed");
          }
        });
         return false;
     });

I also tried the jQuery post method:

$('#peUpdateForm').submit(function(e){
    $.post('/chargeback/savepe/', $('#peUpdateForm').serialize(), function(data){ 
       alert("success");
    });
    e.preventDefault();
});

I’m not getting anything. Not getting any of my alerts. Not getting any errors from the view (if I just navigate to the view directly I get the expected {‘msg’:’failed’} displayed in the browser, so the json response is fine. The url calls the correct view. The only thing I can think of is my jQuery code is wrong, but I can’t figure out where, and there are no errors in the console. I’ve tested, in the console, the

$('#peUpdateForm').serialize()

and I get the expected value. Pulling my hair out here… Thanks.

EDIT: Adding HTML as my post method isn’t even getting called when I place a breakpoint there, so something may be wrong with how my submit is being set up.

<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable ui-dialog-buttons" style="outline: 0px; z-index: 1002; position: absolute; height: auto; width: 376px; top: 75px; left: 408px; display: block;" tabindex="-1" role="dialog" aria-labelledby="ui-id-8"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
<span id="ui-id-8" class="ui-dialog-title">Project Entry Update</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button"><span class="ui-icon ui-icon-closethick">close</span></a></div>
<div id="addPEForm" style="width: auto; min-height: 0px; height: 365px;" class="ui-dialog-content ui-widget-content" scrolltop="0" scrollleft="0">
    <form method="post" id="peUpdateForm" action="">
    <div style="display:none">
        <input type="hidden" name="csrfmiddlewaretoken" value="wvzwSBl87vC1tbkbdfxsD82GnjtvJCSz"></div>

    <p><label for="id_departmentid">Department:</label>
    <select id="id_departmentid" class="projEntryControl" name="departmentid">
        <option value="" selected="selected">Choose a Department</option>
        <option value="1">ABND</option>
        <option value="2">ATT</option>
        <option value="3">AVI</option>
        <option value="4">CCS</option>
        <option value="5">PBW</option>
    </select></p>
    <p><label for="id_projectid">Project:</label>
    <select id="id_projectid" class="projEntryControl" name="projectid">
         <option value="-1">Choose a Project</option>
         <option value="undefined">Bexar Street</option>
         <option value="undefined">Chalk Hill</option>
         <option value="undefined">Crown Road</option>
    </select>
    </p>
    <p><label for="id_progNumId">Program Number:</label>
    <select id="id_progNumId" class="projEntryControl" name="progNumId">
        <option value="" selected="selected">Choose a Program Number</option>
        <option value="1">31664</option>
        <option value="2">DD-7081</option>
    </select></p>
    <p><label for="id_hoursWorked">Hours Worked:</label>
    <input name="hoursWorked" value="0.0" class="projEntryControl" maxlength="5" type="text" id="id_hoursWorked"></p>
    <p><label for="id_notes">Notes:</label>
    <textarea id="id_notes" rows="10" cols="40" name="notes"></textarea></p>
</form>
</div>

…

  • 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-15T02:56:34+00:00Added an answer on June 15, 2026 at 2:56 am

    AFAIK, Here’s the way to do it right, if you want to keep the button outside:

     $('#button').on('click', function(){
          $.ajax({
                 data: $('#form').serialize(),
                 ...});
     });
    

    This because `$(‘#form’).submit() gets called only if you keep the submit button inside the form tags.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.