Welcome Guest, Not a member yet? Register   Sign In
Ajax base Form validation?
#11

[eluser]InsiteFX[/eluser]
As you can see it removes when it sees script not hte <> tags.
Code:
<$cript type="text/javascript" src="&lt;?=base_url()?&gt;assets/js/site.js"></$cript>
Change s to a $

InsiteFX
#12

[eluser]Unknown[/eluser]
I'm trying to get my form working with Ajax.
The code of my Jquery looks like this
Code:
$(document).ready(function() {
    $('#inschrijfform').submit(function(e){
        $('#errors').hide();
        e.preventDefault();
        $.post($(this).attr('action'),$(this).serialize(),function(data){
            //console.log(data);
            if (data.status){
                $('#errors').html(data.msg).fadeIn('slow').css({'color':'green', 'border':'1px solid green', 'padding':'20px', 'display': 'inline-block'});
            } else {
                $('#errors').html(data.msg).fadeIn('slow').css({'color':'red', 'border':'1px solid #FF3333', 'padding':'20px', 'display': 'inline-block'});
            }

        }, 'json');
    });
});
my controller likes this:
Code:
function send($titel = "")
    {
        $this->load->library('form_validation');
        $this->load->model("inschrijven_model");
        
        if ($this->form_validation->run('zomerkamp') == FALSE)
        {
            if(IS_AJAX)
            {
                $data = array (
                    'status' => false,
                    'errors' => validation_errors()
                );
                echo json_encode($data);
            }
            else
            {
                $page_init = array('location' => 'inschrijven_succes');
                $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
                $this->fuel_page->render();
            }
        }
        else
        {
            if($this->inschrijven_model->insert_inschrijving_Zomerkamp())
            {

                $page_init = array('location' => 'inschrijven');
                $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);
                $this->fuel_page->render();
            }
            else
            {
                echo "Inschrijving ging fout";
            }
        }
    }
When I using Firebug I can see the form values are beeing posted but the response get an error. I got and internal server error what saying: An Error Was Encountered
Unable to locate the file: includes/template.php

Does someone know what this mean?
#13

[eluser]InsiteFX[/eluser]
If you are running CI 2.0+ and using jQuery post, then read this article by Eric Barnes!

CodeIgniter CSRF Protection With Ajax

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB