I want to use jquery .on()
to do the AJAX
Anyway,I test two method below,both of them works
I want to know what's the difference between them??
are the both method correct?
<script type="text/javascript">
/*method 1*/
/*$(document).on('submit', '.login-form', function(){ */
$(document).on('click', '.searchtitle', function(){
ttest = $(this).serialize();
console.log(ttest);
});
/*method 2*/
$(".searchtitle").on('click', function(){
ttest = $(this).serialize();
console.log(ttest);
});
</script>
test.html
<form action="" method="post" class="searchtitle">
{% csrf_token %}
search activity :<input type="text" name="title">
<button type="button" class="btn .btn-sm btn-success" id="search">submit</button>
</form>