새로운 정렬 정렬 배열을 내 ajax 파일로 보내려고합니다.
정렬 후 정렬 정렬을 위해 JQUERY UI 를 사용 하고 있습니다. 정렬 된 배열을 auction.ajax.php 파일 로 가져 오고 싶습니다 .
나도 배열을 준비해 보았습니다. 재정렬 된 파일 이름 배열을 ajax 페이지로 보내야합니다.
<script>
$(document).ready(function(e) {
var imageNames = [];
$(function() {
$("#myDrop").sortable({
items: '.dz-preview',
cursor: 'move',
opacity: 0.5,
containment: '#myDrop',
distance: 20,
tolerance: 'pointer',
});
$("#myDrop").disableSelection();
});
//Dropzone script
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#myDrop", {
paramName: "files", // The name that will be used to transfer the file
addRemoveLinks: true,
uploadMultiple: true,
autoProcessQueue: false,
parallelUploads: 50,
maxFilesize: 2, // MB
acceptedFiles: ".png, .jpeg, .jpg, .gif",
url: "ajax/actions.ajax.php",
});
/*Ans code*/
myDropzone.on("sending", function(file, xhr, formData) {
var filenames = [];
$('.dz-preview .dz-filename').each(function() {
filenames.push($(this).find('span').text());
});
formData.append('filenames', filenames);
});
/* Add Files Script*/
myDropzone.on("success", function(file, message) {
$("#msg").html(message);
//setTimeout(function(){window.location.href="index.php"},800);
});
myDropzone.on("error", function(data) {
$("#msg").html('<div class="alert alert-danger">There is some thing wrong, Please try again!</div>');
});
myDropzone.on("complete", function(file) {
//myDropzone.removeFile(file);
});
$("#add_file").on("click", function() {
myDropzone.processQueue();
});
});
</script>
<div class="dropzone dz-clickable" id="myDrop">
<div class="dz-default dz-message" data-dz-message="">
<span>Drop files here to upload</span>
</div>
</div>
<input type="text" name="sortingOrder" id="sortingOrder" value="">
<button id="add_file">Add</button>
이를 수행하는 한 가지 방법은 sending
이벤트 를 사용하는 것 입니다. 이 이벤트는 formData
매개 변수로 수신 되므로 수정할 수 있으며 데이터를 서버로 보낼 수 있습니다.
myDropzone.on("sending", function(file, xhr, formData) {
var filenames = [];
$('.dz-preview .dz-filename').each(function() {
filenames.push($(this).find('span').text());
});
formData.append('filenames', filenames);
});
이제 각 호출은 매개 변수로 구성되며 filenames
dropzone에있는 모든 파일의 정렬 된 이름을 포함합니다.
이 작동하는 플 런커를 참조하십시오 . 스타일이 적용되지 않았지만 추가 버튼 을 클릭하면 콘솔에서 파일 이름을 볼 수 있습니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다