$(function () { btnFace("1"); btnFace("2"); }); function btnFace(imageIndex) { var fData = { UploadImage: true, imageIndex: imageIndex }; fData[common.csrfParam] = common.csrf; new afuButton({ uploadURI: $("input[name='url_upload_face']").val(), formData: fData, wrap: { tagName: 'div', classes: '' }, fileExtension: '.png,.jpg,.jpeg,.gif', fileSizeLimit: 1, classes: 'btn btn-default', fakeInputContent: ' Chọn hình ảnh', onUploaded: function (data) { $("#face" + imageIndex).attr("src", "/data/uploads" + data); common.uploadBlock(false); compareFace(); } }).addInstance('image' + imageIndex); } function compareFace() { var face1 = $("#face1").attr("src"); var face2 = $("#face2").attr("src"); if (face1 == "/images/user2-160x160.jpg" || face2 == "/images/user2-160x160.jpg") return; common.modalBlock(true); $.ajax({ url: $("input[name='url_face_comparison']").val(), type: 'POST', data: { face1: face1, face2: face2 }, success: function (data) { common.modalBlock(false); $("#percent").html(data.type1 + "%
[" + data.type2 + "%]"); }, error: function (jqXHR, textStatus, errorThrown) { common.modalBlock(false); common.ajaxError(); } }); }