I am looking one solution for combine multi selectors and different event handlers for execute my funcion.
My question: i have a form with all data that pass to php by ajax. Now i send it by submit input, and .on 'submit' event, but i need execute it also by another event click with another class, example an checkbox.
Inside form have class .formdataaj and inside an checkbox called .checkbox_ajx (i use it like switch for pass var 1 or 0 to php, activate or disactivate my posts)
my code:
$('.formdataaj').each(function(){
$(this).on('submit',function(e){
var className=$(this);
e.preventDefault();
var form_data = new FormData(this);
//console.log(...form_data);
$.ajax({
type: 'post',
url: 'php/extra_update.php',
data: form_data,
processData:false,
contentType:false,
cache: false,
success: function(data)
{
console.log(data);
//get parse json data
var jsondata = $.parseJSON(data);
console.log(jsondata);
}
})
})
})
Thank you