Upload Images and Create Product
jQuery(document).ready(function($) {
$('#upload-form').on('submit', function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url: ajaxurl, // WordPress AJAX handler
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
if (response.success) {
// Append the HTML response to a div with id "post-results"
$('#post-results').html(response.data);
} else {
alert('Error occurred: ' + response.data);
}
},
error: function(xhr, status, error) {
console.log(error);
}
});
});
});