Welcome Guest, Not a member yet? Register   Sign In
Not submitting form
#1

[eluser]xtremer360[/eluser]
My form will validate on the client side but I'm trying to figure out why its not validating on the server side. I don't have my php complete but its not even bringing up the POST request in my console saying its submitting the form to the server.

jQuery:

Code:
$(document).ready(function()
{

/*
* Validate the form when it is submitted
*/
var validateform = $("#newArticleForm").validate({
    invalidHandler: function(form, validator) {
        var errors = validator.numberOfInvalids();
        if (errors) {
            var message = errors == 1
            ? 'You missed 1 field. It has been highlighted.'
            : 'You missed ' + errors + ' fields. They have been highlighted.';
            $('.box .content').removeAlertBoxes();
            $('.box .content').alertBox(message, {type: 'warning', icon: true, noMargin: false});
            $('.box .content .alert').css({
                width: '100%',
                margin: '0',
                borderLeft: 'none',
                borderRight: 'none',
                borderRadius: 0
            });
        } else {
            $('.box .content').removeAlertBoxes();
        }
    },
    showErrors : function(errorMap, errorList) {
        this.defaultShowErrors();
        var self = this;
        $.each(errorList, function() {
            var $input = $(this.element);
            var $label = $input.parent().find('label.error').hide();
            $label.addClass('red');
            $label.css('width', '');
            $input.trigger('labeled');
            $label.fadeIn();
        });
    },
    submitHandler: function(form) {
        var dataString = $('#newArticleForm').serialize();
        $.ajax({
            type: 'POST',
            url: '/kowmanager/dashboard/articleSubmit',
            data: dataString,
            dataType: 'json',
            success:  function(data) {
                if (data.error) {
                    $('.box .content').removeAlertBoxes();
                    $('.box .content').alertBox(data.message, {type: 'warning', icon: true, noMargin: false});
                    $('.box .content .alert').css({
                        width: '',
                        margin: '0',
                        borderLeft: 'none',
                        borderRight: 'none',
                        borderRadius: 0
                    });
                }
                else
                {
                    $('.box .content').removeAlertBoxes();
                    $('.box .content').alertBox(data.message, {type: 'success', icon: true, noMargin: false});
                    $('.box .content .alert').css({
                        width: '',
                        margin: '0',
                        borderLeft: 'none',
                        borderRight: 'none',
                        borderRadius: 0
                    });
                    $(':input','#newArticleForm')
                    .not(':submit, :button, :hidden, :reset')
                    .val('');  
                }
            }
        });
    }
});

});

Controller:

Code:
function articleSubmit()
{
    $outputArray = array('error' => 'yes', 'message' => 'unproccessed');
    $outputMsg = '';
    // Sets validation rules for the login form
    $this->form_validation->set_rules('title', 'Title',
        'trim|required|xss_clean|alpha_numeric');
    $this->form_validation->set_rules('category', 'Category',
        'integer');
    $this->form_validation->set_rules('isSticky', 'Is Sticky',
        'integer');
    $this->form_validation->set_rules('comments', 'Allow Comments',
        'integer');    

    // Checks to see if login form was submitted properly
    if (!$this->form_validation->run())
    {
        $outputArray['message'] =
            'There was a problem submitting the form! Please refresh the window and try again!';
    }
    else
    {

    }
}

View:

Code:
<?php $attributes = array('class' => 'validate', 'id' => 'newArticleForm'); ?>
            <?php echo form_open_multipart('', $attributes) ?>
                <div class="content no-padding">
                    <div class="section _100">
                        &lt;?php echo form_label('Title', 'title'); ?&gt;

                        <div>
                            &lt;?php echo form_input('title', '', 'class="required"'); ?&gt;
                        </div>
                    </div>

                    <div class="section _100">
                        &lt;?php echo form_label('Category', 'category'); ?&gt;

                        <div>
                            &lt;?php echo form_dropdown('category', $categories, '', 'class="required"'); ?&gt;
                        </div>
                    </div>

                    <div class="section _100">
                        &lt;?php echo form_label('Is Sticky', 'sticky'); ?&gt;

                        <div>
                            &lt;?php
                                                            $options = array(
                                                                        ''   => 'Please Select An Option',
                                                                        '0'  => 'No',
                                                                        '1'  => 'Yes',
                                                                     );
                                                            ?&gt;&lt;?php echo form_dropdown('sticky', $options, '', 'class="required"'); ?&gt;
                        </div>
                    </div>

                    <div class="section _100">
                        &lt;?php echo form_
#2

[eluser]Matalina[/eluser]
Code:
&lt;?php echo form_open_multipart('', $attributes) ?&gt;

Where is it going?
#3

[eluser]xtremer360[/eluser]
That's for the jQuery to handle.
#4

[eluser]Matalina[/eluser]
your url may be wrong in your handler.

Code:
url: '/kowmanager/dashboard/articleSubmit',

Not that it's common practice but I'd have a default if javascript was turned off form to go thru.


#5

[eluser]xtremer360[/eluser]
Its not even bringing up the post request though. And its the same jquery as my other forms. I just don't see what's breaking it.

#6

[eluser]InsiteFX[/eluser]
Code:
url: &lt;?php echo base_url();?&gt; + 'kowmanager/dashboard/articleSubmit',

Or you can add this to your html head tag.
Code:
// replace $ in script with s
<$cript type="text/javascript" charset="utf-8">
    //&lt;![CDATA[
        var base_url = "&lt;?php echo base_url(); ?&gt;";
        var site_url = "&lt;?php echo site_url(); ?&gt;";
    // ]]>
</$cript>

url: base_url + 'kowmanager/dashboard/articleSubmit',
url: site_url + 'kowmanager/dashboard/articleSubmit',
#7

[eluser]xtremer360[/eluser]
For some reason its not working. I'm going to send you a PM message on here.
#8

[eluser]InsiteFX[/eluser]
Try this:
Code:
url: base_url + 'dashboard/articleSubmit',

kowmanager is your directory id bet, which should be on your base_url

#9

[eluser]xtremer360[/eluser]
Tried again and still isn't putting the POST in the console.




Theme © iAndrew 2016 - Forum software by © MyBB