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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:19:41+00:00 2026-05-19T01:19:41+00:00

Few questions: I’m using CI and JQuery AJAX. In my code below, I assemble

  • 0

Few questions:

I’m using CI and JQuery AJAX.

In my code below, I assemble dataString, which by default, is appended to the URL as a query string.

I’ve changed the AJAX “type” to POST, so my question is – how do I access dataString in my CI app?

It would seem I still have to use

$name=$this->input->post('name')

Which to me, makes setting dataString redundant?

—

I’ve tried searching but can’t really find anything concrete.

Would it be possible to still make use of CIs validation library and AJAX?

if($this->form_validation->run() == FALSE)
{
    // what can i return so that my CI app shows errors?
}

Normally you would reload the contact form or redirect the user. In an ideal world I would like the error messages to be shown to the user.

Jquery:

    $(document).ready(function($){
        $("#submit_btn").click(function(){
            var name = $("input#name").val();
            var company = $("input#company").val();
            var email = $("input#email").val();
            var phone = $("input#phone").val();
            var message = $("textarea#message").val();
            var dataString = 'name=' +  name + '&message=' + message + '&return_email=' + email + '&return_phone=' +
            phone + '&company=' + company;
            var response = $.ajax({
                type: "POST",
                url: "newsite/contact_ajax/",
                data: dataString
            }).responseText;

            //$('#contact').hide();
            //$('#contact').html('<h5>Form submitted!  Thank you!</h5><h4>We will be in touch with you soon.</h4>');
            //$('#contact').fadeIn('slow');
            return false;
        });  
    });

hope i’ve been clear enough – if anyone has a decent example of a CI contact form that would be great. there’s mixed stuff on the internet but nothing that hits all the boxes.

thanks

  • 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-19T01:19:41+00:00Added an answer on May 19, 2026 at 1:19 am

    As I wrote in the comments, you don’t need to set a dataString since jQuery can do it for you:

    $(document).ready(function($){
        $("#submit_btn").click(function(){
            var response = $.ajax({
                type: "POST",
                url: "newsite/contact_ajax/",
                data: $(your_form_id).serialize()
            }).responseText;
    
            //$('#contact').hide();
            //$('#contact').html('<h5>Form submitted!  Thank you!</h5><h4>We will be in touch with you soon.</h4>');
            //$('#contact').fadeIn('slow');
            return false;
        });  
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few questions. First of all does code below violates law of Demeter?
In the reply to few questions , Jonathan Oliver mentions using an AsynchronousCommitDispatcher to
I have a few questions about boost::regex: I tried an example below. 1) What
I have few questions connected with struct and typedef, there is piece of code
I have a few questions about ARC (automatic reference counting): CFURLRef url = (__bridge
I have a few questions regarding android source code download, repo / git. This
I have few questions about this code: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv =
I have a few questions about security using PHP, I dont want to use
i have a few questions about flash web sites. are their pages done using
I have a few questions regarding Compact SQL. I am using VS C# 2008

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.