Estou recebendo esse erro em vários arquivos.
Uncaught SyntaxError: Unexpected token <
O debugger diz que é arquivo .js, porém me manda para os arquivos html e mostra o erro logo na primeira linha do html, onde tem o doctype. Não existe erro de sintaxe pois o código apenas foi copiado de um projeto já existente.
Algumas funcionalidades e os métodos dentro dos arquivos .js deixaram de funcionar.
Alguém consegue me ajudar com esse erro? Tudo que encontro é nada relacionado ao que preciso.
Segue os arquivos os quais o debugger reclama o erro:
script.js
$(document).ready(function(){
$('.inicial .btn-login').click(function(){
$('body').addClass('inicial-login');
});
$('#voltarHome').click(function(){
$('body').removeClass('inicial-login');
});
$('.nav-img').click(function(){
$('.nav-links').toggle('300');
$('.sidebar').removeClass('on');
});
$('.click-sidebar').click(function(){
$('.sidebar').toggleClass('on');
$('.nav-links').hide('300');
});
$('#post-categoria').change(function(){
if( $(this).val() == 'venda'){
$('#vendaetroca').toggle('100');
}
});
});
vue-api-register-candidate.js
import Form from './core/Form';
//import Axios from 'axios';
/*Os seguintes imports estão comentandos e deixados no código para possível uso futuro*/
//import Modal from './components/Modal.vue';
//import Datepicker from "./vue2-datepicker.js";
var vm = new Vue({
el: '#candidate-register',
data: {
form: new Form(),
image: "./img/img-placeholder.png",
name_image: "",
name: "",
name_file_video: "",
name_file: "",
resume_file: "",
video_file: "",
selectFunction: "",
cpf: "",
email: "",
cellphone: "",
state: "",
neighborhood: "",
city: "",
adress: "",
street_number: "",
complement: "",
hiring_type: "",
intended_salary: "",
description: "",
complement: "",
id: "",
id_user: "",
password: "",
password_confirm: "",
logged: false,
},
mounted() {
if (localStorage.getItem('id') != null) {
this.logged = true;
}
},
created: function () {
if (localStorage.getItem('id') != "" && localStorage.getItem('id_user')) {
axios.defaults.headers.post['Authorization'] = 'Bearer ' + localStorage.getItem('token');
axios.defaults.headers.post['Accept'] = 'application/json';
axios.defaults.headers.post['Content-Type'] = 'application/json';
//Traz o candidato logado. URL de edição de candidate
axios.post("url_aqui", {
id: localStorage.getItem('id')
}).then(response => {
console.log(response.data.data);
this.image = response.data.data.profile_image;
this.name = response.data.data.name;
this.cpf = response.data.data.cpf;
this.email = response.data.data.email;
this.cellphone = response.data.data.cellphone;
this.state = response.data.data.state;
this.neighborhood = response.data.data.neighborhood;
this.city = response.data.data.city;
this.adress = response.data.data.adress;
this.street_number = response.data.data.street_number;
this.complement = response.data.data.complement;
this.hiring_type = response.data.data.hiring_type;
this.intended_salary = response.data.data.intended_salary;
this.description = response.data.data.description;
this.resume_file = response.data.data.resume_file;
this.selectFunction = response.data.data.id_function_candidate;
this.id = response.data.data.id;
this.id_user = response.data.data.id_user;
this.complement = response.data.data.complement;
this.video_file = response.data.data.video_file;
}).catch(error => {
console.log(error);
})
}
},
methods: {
processForm() {
if (this.id == "" && this.id_user == "") {
this.form.data.name = this.name;
this.form.data.cpf = this.cpf;
this.form.data.email = this.email;
this.form.data.cellphone = this.cellphone;
this.form.data.state = this.state;
this.form.data.neighborhood = this.neighborhood;
this.form.data.city = this.city;
this.form.data.adress = this.adress;
this.form.data.street_number = this.street_number;
this.form.data.complement = this.complement;
this.form.data.hiring_type = this.hiring_type;
this.form.data.intended_salary = this.intended_salary;
this.form.data.description = this.description;
this.form.data.name_image = this.name_image;
this.form.data.name_file_video = this.name_file_video;
this.form.data.name_file = this.name_file;
this.form.data.id_function_candidate = this.selectFunction;
this.form.data.complement = this.complement;
this.form.data.password = this.password;
this.form.data.password_confirm = this.password_confirm;
this.form.data.id = null;
this.form.data.id_user = null;
this.form.submit("url_aqui", this.onSuccess);
} else {
this.form.data.name = this.name;
this.form.data.cpf = this.cpf;
this.form.data.email = this.email;
this.form.data.cellphone = this.cellphone;
this.form.data.state = this.state;
this.form.data.neighborhood = this.neighborhood;
this.form.data.city = this.city;
this.form.data.adress = this.adress;
this.form.data.street_number = this.street_number;
this.form.data.complement = this.complement;
this.form.data.hiring_type = this.hiring_type;
this.form.data.intended_salary = this.intended_salary;
this.form.data.description = this.description;
this.form.data.name_image = this.name_image;
this.form.data.name_file_video = this.name_file_video;
this.form.data.name_file = this.name_file;
this.form.data.id_function_candidate = this.selectFunction;
this.form.data.complement = this.complement;
this.form.data.id = this.id;
this.form.data.id_user = this.id_user;
this.form.data.password = this.password;
this.form.data.password_confirm = this.password_confirm;
this.form.submit("url_aqui", this.onSuccess);
}
},
onSuccess(response) {
try {
if (response.data.result == true) {
if(localStorage.getItem('id') == null){
alert("Cadastro realizado com sucesso!\nVocê será redirecionado para fazer o login.");
window.location.href = "index.html";
}else{
alert("Edições salvas!");
}
this.form.reset();
this.$refs.modal.configModal('Sucesso', 'Registro salvo!', 'OK', '', function () {
util.goBack();
});
this.$refs.modal.show(2500);
} else {
alert(response.data.msg);
this.$refs.modal.configModal('Aviso', response.data.msg, '', 'OK');
this.$refs.modal.show();
}
} catch (e) {
console.log(e);
}
},
//Para Salvar Imagem
onFileChange(e, type) {
var files = e.target.files || e.dataTransfer.files;
if (type == 1) {
this.name_image = files[0].name;
} else if (type == 0) {
this.name_file_video = files[0].name;
} else {
this.name_file = files[0].name;
}
if (!files.length)
return;
this.createImage(files[0], type);
},
createImage(file, type) {
var image = new Image();
var reader = new FileReader();
var vm = this;
if (type == 1) {
reader.onload = (e) => {
vm.image = e.target.result;
this.form.data.image_b64 = e.target.result;
};
reader.readAsDataURL(file);
} else if (type == 0) {
reader.onload = (e) => {
this.form.data.video_b64 = e.target.result;
};
reader.readAsDataURL(file);
} else {
reader.onload = (e) => {
this.form.data.file_b64 = e.target.result;
};
reader.readAsDataURL(file);
}
},
backToHome() {
if (this.id == localStorage.getItem('id')) {
console.log("entrou no if");
localStorage.clear();
window.location.href = "index.html";
} else {
console.log("entrou no else");
window.location.href = "index.html";
}
}
}
})
Desde já agradeço.