I know that it is better to use delegation binding for any html elements that is dynamically added. This may be simple but I don't get the proper "id" of the form element.
$(document).on("submit", "form#add_education", function(e){
e.preventDefault();
console.log($(this));
$.ajax({
url : $(this).attr('action'),
type : $(this).attr('method'),
data : $(this).serialize(),
dataType: 'json',
success : function (json){
$('.view-educationsec').css('display','none');
$(this)[0].reset();
showEducation();
swal("Good job!", "Education saved successfully!", "success");
},
error: function(json){
if (json.status === 422) {
// $("#errorMessage").text('There is an error occured. Please try again.');
swal("Something went wrong!", "Please contact the developer for this issue.", "error");
}
}
});
$("html").removeClass("no-scroll"); // para ma enable ang scroll sa browser
});
Console.log returns alright, but the ajax function will result to
"Uncaught TypeError: $(...)[0].reset is not a function"
I'm guessing that ajax is also not passing data to the controller because of the improper id format being used.