jQuery(document).ready(function(){
 
    // Cancel form submition, return false
    jQuery("#loginForm").submit(function(){
        return false;
    });
 
    // Manage submit button click event
    jQuery("#submnit").click(function(){
 
        // Call some function to handle Ajax request
        FormAjaxStuff();
    });
 
 
}); // End of jQuery(document).ready
 
function FormAjaxStuff(){
    var q1 = jQuery("#q1").attr("value");
    var q2 = jQuery("#q2").attr("value");
    var q3 = jQuery("#q3").attr("value");
    var q4 = jQuery("#q4").attr("value");

	var refr = jQuery("#refr").attr("value");
 
 
    jQuery.ajax({
        type: "POST",
        url: "ocena_przetworz.hdb",
        dataType: "html",
        data: "q1=" + q1 + "&q2=" + q2 + "&q3=" + q3 + "&q4=" + q4 + "&refr=" + refr,
        success: function(response){
 
            // if sucessful; response will contain some stuff echo-ed from .php
            // quick tect: alert("Here is your response: " + response);
 
            // Append this response to some <div> => let's append it to div with id "serverMsg"
 
            jQuery("#serverMsg").replaceWith(response);
        },
        error: function(){
            alert("Error occured during Ajax request...");
        }
    });
} // END OF FormAjaxStuff()
