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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:27:35+00:00 2026-05-29T15:27:35+00:00

I want to submit a form using jQuery in a CodeIgniter application. However, the

  • 0

I want to submit a form using jQuery in a CodeIgniter application. However, the function called in the Controller keeps wanting to send the user to a page (with the same name as the Controller function) that doesn’t exist.

I have tried this:

$('#contactForm').submit(function () {

});

And this:

$('#contactForm').submit(function () {
    dataString = $("#contactForm").serialize();
    $.ajax({
        type:"POST",
        url:"<?php echo base_url(); ?>about/contactSubmit",
        data:dataString,

        success:function (data) {
            alert('test');
        }

    });

    return false;  //stop the actual form post !important!
});

The form is a simple form with id “contactForm”. The jQuery submit function works in that it goes to the “contactSubmit” function in the Controller. This function looks like this:

public function contactSubmit()
{

    $this->load->model('customer_model');
    $this->customer_model->addCustomer();
}

So it calls an addCustomer function in the Model that adds the info in the database. All that works fine. But then it tries to open a “customerSubmit” page that doesn’t exist, and that’s what I want to avoid. I just want it to stay on the same page, that has a jQuery function for telling the user that the form has been submitted ok.

So how do I do this?

EDIT:

It seems the key to not being sent to a new page by the Controller function contactSubmit is to return false in the submit jQuery function, judging from every tutorial on the subject I can find, but…when I do include that, the Controller function isn’t called at all. This means that only the first option above really calls the Controller function (i.e. the .submit without return false).

So what am I doing wrong here? If I’m supposed to pass data to the database using a submit, but the “return false” stops it from actually calling the function in the Controller?

EDIT 2:
Found the answer, see my comment to Christophs post!

  • 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-29T15:27:36+00:00Added an answer on May 29, 2026 at 3:27 pm

    Just a guess: Try event.preventDefault() to stop the default behaviour of the submit action which is defined in <form action="..."> (Which is normally sending the form-data and forwarding to some kind of “request received” page).

    The code would be something like this:

    $('#contactForm').submit(function (event) {
        dataString = $("#contactForm").serialize();
        $.ajax({
            type:"POST",
            url:"<?php echo base_url(); ?>about/contactSubmit",
            data:dataString,
    
            success:function (data) {
                alert('test');
            }
    
        });
        event.preventDefault();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to submit a form using jquery .post() . I want to send
I have a form. I want to add an event handler using jquery. $(form).submit(function
So what I want to do is to submit a form using jQuery's AJAX
i want to submit a form with about 10 input using jquery/ajax,but i don't
I'm using Jquery to submit a form. I want to loop through the form
dear all i want to know how to submit asp.net form data using jquery
I am using jquery validate with a form. I want to submit the form
I am using JQuery onclick submit event like this <script type=text/javascript> $(function(){ $('#button').click(function(){ $('#form').submit();
I am using html, javascript & mod_python. I want to submit html form. To
I have a form, when user submit the form, I want to direct the

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.