samedi 2 juillet 2016

onClick jQuery Function not Trigging


I'm trying to make this simples onclick work... But in my file.js 80% of them work and this one (for example) don't!

If someone could just help me out...

Function:

    jQuery(document).on("click", '#avatarGO', function(event){

toastr.clear();

jQuery('#avatarGO').addClass('disabled');

jQuery('.has-error').removeClass('has-error');

var formData = $("#changeAvatarForm").serialize();

jQuery.ajax({
    type        : 'POST',
    url         : '../../class/profile/change_avatar.php',
    data        : formData,
    dataType    : 'json'
})
.done(function(data) {

    console.log(data);

    if (!data.success){

        //Failure
        jQuery.each(data.sysemp, function(index, value){

          jQuery('#'+value+'').addClass('has-error');

        });

        //Failure
        jQuery.each(data.syserr, function(index, value){

           toastr["error"](value);

        });

        jQuery('#avatarGO').removeClass('disabled');

    } else {

        //Success
        toastr["success"](data.message);
        setTimeout(function() { window.location.reload(); }, 850);

    }

});

event.preventDefault();

});

HTML:

<button id="avatarGO" type="button" class="btn btn-block btn-success">Confirmar</button>

Full File: https://www.ertheya.com/assets/plugins/kCore.js

Updates:

The console isnt showing errors The form onClick isnt triggered The HTML is correct


Aucun commentaire:

Enregistrer un commentaire