Good day!
There is a registration form. There is such a script:
$(function() { $("#form-regis").submit(function(e) { e.preventDefault(); var formURL = $(this).attr("action"); var formmethod = $(this).attr("method"); var postData = $(this).serialize(); $.ajax({ type: formmethod, url: formURL, data:postData, cache: false, success: function (data) { console.log(data); } }); return false; }); }); My scanty knowledge of JavaScript and jQuery does not leave me the opportunity to bring all this to the page. The registration form in the modal window, so I can not do without Ajax . In the console, I accept an array of errors, namely those that I admit when filling out the form. Help to bring them to the list on the page. First, I’ll have to figure it out, and then I’ll need to hide the form in the absence of errors and deduce that the registration is successful and a confirmation email has been sent to the post office.
I apologize for the incomplete information. The data comes in JSON format, in such a structure "field: array / error object"
Now did this:
success: function (errors) { console.log(errors); var out = ''; if (errors[0].name) out += "<p>"+errors[0].name+"</p>"; if (errors[0].email) out += "<p>"+errors[0].email+"</p>"; if (errors[0].password) out += "<p>"+errors[0].password+"</p>"; $('#errors-block').html(out).fadeIn(); } But if you fill without errors, swears with this line:
Uncaught TypeError: Cannot read property 'name' of undefined Laravel 5
JS, then do not undertake to impose yourself - just spend your nerves. And on the issue - little data. What format is the data received in? How should they be displayed and where (usually this is dictated by the theme of the site)? - user207618 pm