<form id="importFormat">

    <div class="single">
        <div class="row">
            {{ inputAdvance('TEXT', {
                'titre' : 'Identification du format' | trad,
                'name' : 'newID',
                'pathValidator' : path('Ajax.validator.isStringSansEspace'),
                'paramsValidator' : "{'sizeMin' : '1', 'sizeMax' : '30'}",
                'obligatoire' : true,
                'inputAttr' : {
                    'oninput' : 'this.value = this.value.toUpperCase()',
                },
            }) }}
        </div>
        <div class="row">
            {{ inputAdvance('FILE', {
                'name' : 'importFormat',
                'obligatoire' : true,
            }) }}
        </div>
        <div id="messageErreur" class="error"></div>
        <button style="margin-top:10px;" class="principal btn btn_right" type="button" onClick="functionImportFormat();">{{ 'Importer' | trad }}</button>
    </div>
</form>

<script>
		function functionImportFormat()
		{
            jForm.append("newID", $('[name="newID"]').val());

        	$.ajax({
        		url: '{{ path('Catalogue.Format.importJson') }}',
                type: 'POST',
        	  	dataType : 'JSON',
                data: jForm,
                mimeType: "multipart/form-data",
                contentType: false,
                cache: false,
                processData: false,
        		success: function(data){
                    desactiveLoader();
                    desactivePopup();

                    redirectJSWithPost(data.path, data.post);
        		}, error: function (data){
                    desactiveLoader();
                    var data = jQuery.parseJSON(data.responseText);
                    $('#messageErreur').html(data.message);
                }
        	});
		}

        /*function functionImportFormat()
        {
            activeLoader();
            $.ajax({
                dataType : 'html',
                url: '{{ path('Catalogue.Format.importJson') }}',
                type: "POST",
                data: $('#importFormat').serialize(),
                success: function(result){
                    const data = JSON.parse(result);
                    desactiveLoader();
                    desactivePopup();

                    redirectJSWithPost(data.path, data.post);
                }, 
                error: function (data){
                    desactiveLoader();
                    var data = jQuery.parseJSON(data.responseText);
                    $('#messageErreur').html(data.message);
                }
            });	 
        }*/
</script>