Reputation: 17
I'm building a library to save watched series and I'm struggling with some sort of incompatibility with my JQuery script. It works as intended in Chrome and Edge but not in Firefox. The reason of this script is to populate a div with content.
<script>
jQuery(document).on('submit', '.seasons_form', function(e){
event.preventDefault();
$.ajax({
type: "POST",
url: $(this).attr("action"),
data: $(this).serialize(),
success:function(data){
;
document.getElementById("chapters_container").innerHTML = (data);
},
error:function(xhr,exception)
{
}
})
e.preventDefault();
});
</script>
In Firefox it redirects me to the function I'm calling instead of populating the div. I have read several similar problems here but I can not find the solution.
Is anyone able to help? Thanks in advance.
Upvotes: 0
Views: 209
Reputation: 1855
You need to pass the event variable with your function in FireFox, such as:
jQuery(document).on('submit', '.seasons_form', function(event) {}
It is a global variable in IE and Chrome etc. but not in FF. As a result you need to pass it explicitly.
Upvotes: 1