I have couple of errors
$errors = array();
$errors['failed'] = "File uplaoded failed Please correct the following error";
$errors['size'] = 'File size must be 100 MB';
$errors['ext'] = "This formate does not support, Only .zip supported";
$errors['exits'] = "Sorry, file name already exists ,Please enter another theme name";
echo json_encode($errors)
$(function() {
$('#addTheme').submit(function(e) {
e.preventDefault(); //ok
var data = new FormData($(this)[0]);
$.ajax({
url: '<?php echo base_url() ?>download/uploaded',
type: 'POST',
data: data,
dataType : 'json',
contentType: false,
cache: false,
processData: false,
success : function(response) {
$('.populate').val('');
var obj = jQuery.parseJSON(JSON.stringify(response));
if(obj.value === 1) {
$('#error').html('<div class="alert alert-success alert-dismissible" role="alert">'+
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'+'File uploaded successfully</div>');
} else {
$('#error').html('<div class="alert alert-success alert-dismissible" role="alert">'+
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'+'File uploaded failed'+ +'</div>');
}
console.log("upload success");
},
});
});
});
i want to display the errors in ajax, i have the above code, how could i display the error in ajax using json. any help would be appreciated.
</div>