I am trying to get the submitting of POST forms to use AJAX. This works, but unfortunately it also appears to be triggering for GET requests. Does anyone know why?
$(document).on('submit', 'form[method=post]', $(this).ajaxForm({...}));
Are you preventing default on the click action? here is an example that shows that your first and second arguments in the .on() method are functioning correctly. Your third argument should be structured like the snippet so that an anonymous function does some form handling.
$(document).ready(function (argument) {
$(document).on('submit', 'form[method=post]', function (event) {
event.preventDefault();
$('.status').html('post')
});
$(document).on('submit', 'form[method=get]', function (event) {
event.preventDefault();
$('.status').html('get')
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="status">click button to change this text</div>
<form method="post"><button type="submit">Post</button></form>
<form method="get"><button type="submit">Get</button></form>
event.preventDefault() in the handler for the get request.