Form isn’t inserting data into database with ajax plugin

I never did figure out how to do this with serialize or formData, but I figured out two other ways to do it. The easiest is to just skip this step altogether and in the action and js url list the url to a php file like you might do if you weren’t in wordpress. I then added this line to the top of it and it worked. require_once( ‘../../../wp-load.php’ ); This is unadvised because of server load and some other reasons I don’t fully understand, but it works.

The second way, if you don’t need to serialize or upload a file, is to do this:

jQuery(document).ready(function(){
jQuery("#submit").click(function(){
var name = jQuery("#dname").val();
var age = jQuery("#age").val();
var File = jQuery("#myfile").val();
jQuery.ajax({
type: 'POST',   // Adding Post method
url: MyAjax.ajaxurl, // Including ajax file
data: {"action": "postlesson", "dname":name, "age":age, "myfile":File}, // Sending data dname to post_word_count function.
success: function(response){ // Show returned data using the function.
jQuery("#feedback").html(response);
}
});
jQuery('[name="age"]').val('');  // sets the field back to empty
jQuery('[name="dname"]').val('');
jQuery('[name="myfile"]').val(''); 
});
});

I’m just posting this in case someone as clueless as me comes looking. This all meant changing the form too. I don’t have that code ready, but essentially, I just got rid of the hidden submit field.