I am facing an issue with the following JS code for AJAX form submission using PHP 8. When I check the chrome browser console, I encounter the error message: "Uncaught SyntaxError: Unexpected token '<', " What could be causing this problem?
$('#add-blog1-form').on('submit', function(e){
e.preventDefault();
let formData = new FormData(this);
let dateTime = new Date();
formData.append('request', "createBlog1");
formData.append('datetime', +dateTime);
$.ajax({
url: 'action.php',
type: "POST",
data: formData,
contentType: false,
cache: false,
processData:false,
success: function(data){
let json_response = JSON.parse(data);
console.log(json_response);
if(json_response.status == "success"){
let forum_category = $('#category').val();
window.location = "categories.php?id="+forum_category;
}else{
alert("Error");
}
},
error: function(){}
});
});