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

A few questions on MS Access databases - Size: Are there limits to the
I have a few questions related: 1) Is possible to make my program change
There are a few questions on SO already regarding LINQ pivots and while a
There are a few questions about configuring Apache for local development, such as this
I have a few questions about data synchronization. The architecture does not seem to
I know there are already a few questions regarding recommendations for C++ unit test
Basically I'm going to go a bit broad here and ask a few questions
I've been hearing about triggers, and I have a few questions. What are triggers?
I've discovered this folder in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and have a few questions. What
I've seen a few similar questions to this one, but none that were quite

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.