Ошибка в браузере
VM7348:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
at Function.parse [as parseJSON] (<anonymous>)
at Object.success ((index):171)
at u (jquery.min.js:1)
at Object.fireWith [as resolveWith] (jquery.min.js:1)
at k (jquery.min.js:1)
at XMLHttpRequest.<anonymous> (jquery.min.js:1)
Сам код:
$(document).ready(function() {
$("form").submit(function(event) {
event.preventDefault();
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(result) {
json = jQuery.parseJSON(result);
if (json.url) setTimeout(redirect, 2000, json.url);
swal({
title: json.header,
text: json.message,
icon: json.status,
});
}
});
});
});
function redirect(url) {
window.location.href = url;
}