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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:17:47+00:00 2026-05-15T15:17:47+00:00

I wanted to ask, why does the response from a ajax request using the

  • 0

I wanted to ask, why does the response from a ajax request using the native ajax not post or get return my entire page? is there anything I should know? I have looked at the documentation on jquery.com and nothing is mentioned of something like that unless i’m looking else where. Can I get any help on why that keeps happening?

This is the function that handles the validation of the form in question.

joe

function showsupport()
{
    $this->form_validation->set_rules('supportername','Your Name','trim|required|max_length[20]|xss_clean');
    $this->form_validation->set_rules('supporteremail','Email Address','trim|required|valid_email|xss_clean');
    $this->form_validation->set_rules('pledgedate','Pledge Date','trim|required|xss_clean');
    $this->form_validation->set_rules('messagetxt','Your Message','trim|required|xss_clean');

    if($this->form_validation->run() == FALSE)
    {
        echo validation_errors();
    } else {

        $this->load->model('support_m');
        $name = $this->input->post('supportername');
        $email = $this->input->post('supporteremail');
        $date = $this->input->post('pledgedate');
        $msg = $this->input->post('messagetxt');

        $qry = $this->support_m->storepledge($name,$email,$date,$msg);

        if($qry){
         //$this->template->write_view('content','thanks');
         //$this->template->render();
         $datamsg['supportmsg'] = 'Message Added Successfully';
        }else{
            echo 'There was an error inserting into db';
        }
    }
}

This is the view with the form generated.

<?php
                                    $formdata = array('id'=>'suppform');
                                    echo form_open('homepage/showsupport',$formdata);

                                    $namedata = array('name'=>'supportname','id'=>'supportname','size'=>'30','max_length'=>'25','value'=>set_value('supportname'));
                                    echo '<label for="supportername">Your Name:'.form_input($namedata).'</label><br /><br />';
                                    $emaildata = array('name'=>'supporteremail','id'=>'supporteremail','size'=>'30','max_lenth'=>'25','value'=>set_value('suppoteremail'));
                                    echo '<label for="supporteremail">Email Address:'.form_input($emaildata).'</label><br /><br />';
                                    $pledgedata = array('name'=>'pledgedate','id'=>'pledgedate','size'=>'30','max_length'=>'20','value'=>set_value('pledgedate'));
                                    echo '<label for="pledgedate">Today\'s Date:'.form_input($pledgedata).'</label><br /><br />';
                                    $msgdata = array('name'=>'messagetxt','id'=>'messagetxt','col'=>'2','rows'=>'8');
                                    echo '<label for="messagetext">Your Pledge:'.form_textarea($msgdata).'</label><br />';
                                    $submitdata = array('name'=>'submitbtn','id'=>'submitbtn','value'=>'Send');
                                    echo '<label for="submitbutton">'.form_submit($submitdata).'</label><br />';

                                    echo form_close();
                                ?>
            </div>
        <div id="errorsechoed"><?php echo validation_errors();?></div>

The html of the retured page is dumped in the div #errorsechoed

$('#suppform').submit(function(eve){
        eve.preventDefault();
    $.ajax({
    type: 'POST',
            cache: false,
    url: 'homepage/showsupport',
    data: $('#suppform').serialize(),
    beforeSend: function(){
                $('#supportform').block({message:'<h4> Processing...</h4>'})
    },
    complete: function(){

    },
    success: function(html){
                $('#errorsechoed').text(html);
    }

            });
});

I have been trying to get this figured out and I think I have made some progress, here is what I have:

a) the template library from William Colin works where regions are specified and so only a particular region will be refreshed all the time and not the only page. As a result it sort of works differently from other standard setups for codeigniter. This is definitely getting in the way of jquery getting a response from the server. It gets the bits of template library (i.e. regions) and renders it out which ends up rebuilding the whole page again.

b) When you run the form_validation library, Template doesn’t allow you to just load a view the normal way in codeigniter, rather you do this by running:

$this->template->write_view('contentregion','viewname'); //writes the view

$this->template->render(); //renders the view on screen.

so if this is not done if validation fails, the error messages spat out by the formvalidation library just never seem to get to the view.

I have tried a lot of permutations of using functions that come with this library and still am just able to render out another page of my site. confused

CONCLUSION:

I think this template library is great but it needs some updating so these issues are met. I will have to look at other templating systems when I have to do a site with a lot of ajax required. Hope Mr. William can see this and help look into this.

Thanks community for an avenue to say what I have learned. Hope this is useful to someone.

  • 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-15T15:17:47+00:00Added an answer on May 15, 2026 at 3:17 pm

    It’s because you are setting the datatype in the postback to be of type ‘html’:

    “html”: Returns HTML as plain text;
    included script tags are evaluated
    when inserted in the DOM.

    if you just want to show that the request succeeded or failed you can have #errorsindicated populated like so:

    success: function(){
                $('#errorsechoed').html('<h4> Request Successfull...</h4>');
    }
    error: function(){
                $('#errorsechoed').html('<h4> Request Failed...</h4>');
    }
    

    you can get more detailed information on the error if you want. See the error option section of the jQuery ajax documentation: http://api.jquery.com/jQuery.ajax/

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

Sidebar

Related Questions

First Sorry for my English. I wanted to ask why ElementName does not work
google produced nothing, so I wanted to ask SO. What does ccp achieve? Here's
just wanted to ask where I define initial class properties? From other languages I
I wanted to ask if there is any way i can get path of
I wanted to ask a quick question just to make sure I am not
I wanted to ask how does Bar code recognition apps works (like Goggles)? Where
Greetings, Currently developing small web service application where response from web service (using CXF
I'm developing a facebook app and wanted to ask if it's possible and does
I think I’m using threads wrong so I wanted to ask if this was
Just wanted to ask you about the drawbacks (I mean memory or reponse time)

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.