Form values are not found from form in jQuery?
<p>I have made my own jQuery plugin, but it has problem that values I set in form are not found in form when I try to generate query string from form. Test it here <a href="http://jsfiddle.net/z3Yff/3/" rel="nofollow">http://jsfiddle.net/z3Yff/3/</a>.</p>

<pre><code>(function($) {

    $.fn.ajaxSubmit = function( options ) {
        // Plugin settings
        var settings = {
            beforeFunction : function() {},
            afterFunction : function() {}
        };

        // Override options
        if ( options ) { 
            $.extend( settings, options );
        }

        // Set variables
        var self = this;

        // Check that form value is set
        var checkValue = function(value) {
            if(value != undefined &amp;&amp; value != null)
            {
                return true;
            }
            return false;
        };

        // Catch submitting input/button
        var submitInputName;        
        $("button, input[type=submit]", this).live("click", function() {
            submitInputName = $(this).attr("name");
        });

        // Submit form
        var submitForm = function(form) {        
            var method = form.attr("method");
            if(!checkValue(method) || method.length == 0) method = "post";
            var action = form.attr("action");
            var query = "";
            var i = 0;
            $("input, button, textarea", $(this)).each(function(index) {
                var name = $(this).attr("name");
                var value = $(this).attr("value");
                var type = $(this).attr("type");
                if(checkValue(value) &amp;&amp; checkValue(name))
                {
                    if(i &gt; 0)
                    {
                        query = query + "&amp;";
                    }
                    query = query + name + "=" + value;
                    i++;
                }
            });
            alert(query); // This is empty String, but it should contain values I enterd to form
            return $.ajax({
                type: method,
                cache: false,
                url: action,
                data: query,
                async: false
            }).responseText;
        };

        // Add ajax submit catching
        this.submit(function() {
            options.beforeFunction();
            submitForm($(this));
            options.afterFunction();
            return false;
        });
    };

})(jQuery);
</code></pre>
