$(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() {
$(this).find('input[type="submit"]').value('Отправлено').addClass('confirm')
},
});
});
});
export const newitem= ({commit}, payload) => {
axios.post('/api/product/add', payload)
.then((response) => {
commit('additem', response.data);
})
}
methods: {
submit(){this.$store.dispatch('prod/newitem, this.$data.form);}
}
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer </script>
$(document).ready(function() {
let onloadCallback = function() {
let divcaptcha = $('g-recaptcha'); // класс, в который будет рендериться капча
for (var i = 0; i < divcaptcha.length; i++) {
grecaptcha.render(divcaptcha[i], {
'sitekey': 'Публичный ключ'
});
}
};
});