Creating an AJAX Submit Form using JavaScript - Tutorial For Beginners

  Рет қаралды 126,362

dcode

dcode

Күн бұрын

Пікірлер: 130
@senju31
@senju31 3 жыл бұрын
Thank you. I wish there more KZbinrs and or persons in general like you. God bless.
@leslinks
@leslinks 4 жыл бұрын
what you have taught us is just awesome. i told you i intend to use procedural way to submit the form after the js validation. but it is more than that. i'm gonna implement this in my project. Thanks mate!
@sajadgholami1137
@sajadgholami1137 4 жыл бұрын
Thanks a lot 'dcode' I learned it completely ♥
@dcode-software
@dcode-software 4 жыл бұрын
No problem!
@omniversal4739
@omniversal4739 4 жыл бұрын
Thanks. I've been trying to use that with prepared statements to avoid sql injection attacks, your tutorial (and some research on Stack Overflow alongside with the php docs) helped me to actually understand how to pass my params into the prepared statement function. Seeing as to how bad my usage of this is because of the repetative code I have to use in my case while writing the logic for my prepared statements, I'm better off making my own php framework or something.
@dcode-software
@dcode-software 4 жыл бұрын
Awesome to hear!
@TomasMisura
@TomasMisura 5 жыл бұрын
thanks a lot for this tutorial ! I have seen a lot of tutorials but this is one the best ones :)
@dcode-software
@dcode-software 5 жыл бұрын
I'm glad to hear that mate! Once again you're very welcome
@senju31
@senju31 3 жыл бұрын
@7:15 - PHP Logic @11:26 - JS Logic
@zomalee4512
@zomalee4512 3 жыл бұрын
How to pass checkbox array??
@shanekanyi7676
@shanekanyi7676 2 жыл бұрын
Hi, I wanted to ask how in the beginning you link the check-login.php file to the index.html file because I don't get anything on the webpage in the network tab of inspect
@shawnbeans7389
@shawnbeans7389 3 жыл бұрын
THANKS FOR TEACHING THIS FOR FREE
@TutunSadhukhan
@TutunSadhukhan 4 жыл бұрын
Thank u so much for such a valuable tutorials...❤❤
@tejjmk5141
@tejjmk5141 6 жыл бұрын
Love Your Stuff 😃
@dcode-software
@dcode-software 6 жыл бұрын
Thanks mate you're welcome!
@svitirur1665
@svitirur1665 4 жыл бұрын
What is the difference between using js ajax for form registration and PHP
@ezequieldasilva1415
@ezequieldasilva1415 3 жыл бұрын
In big projects will help you to decrease the delay of the server, using a handler like this it's convenient because you can have a better UX and also can play a little more with the front-end side.
@sharksean6363
@sharksean6363 4 жыл бұрын
Thank You very much! You've helped me a lot! Nothing I can do for you but subscribed your channel and give you a BIGGGG thumb! You are wonderful! Thanks!
@cloudpuncher4615
@cloudpuncher4615 6 жыл бұрын
your on fire mate :)
@dcode-software
@dcode-software 6 жыл бұрын
🔥🔥🔥
@patrickgeider
@patrickgeider 5 жыл бұрын
Love the voice mate
@dcode-software
@dcode-software 5 жыл бұрын
Thanks mate
@musiclovers8488
@musiclovers8488 4 жыл бұрын
You are awesome dude!! I wanna give you 100000000000000 likes!! ThNks a lot dude
@oliviam830
@oliviam830 Жыл бұрын
why request.open('post') and not 'put'? (very useful vid btw, thank you so much!)
@antonisantoniadis9974
@antonisantoniadis9974 5 жыл бұрын
Thank you sir! Great tutorial with great explanation!
@dcode-software
@dcode-software 5 жыл бұрын
No worries mate!!
@ezequieldasilva1415
@ezequieldasilva1415 3 жыл бұрын
Thanks you a lot, this was very clearfly
@RamuRamu-jp3yy
@RamuRamu-jp3yy 3 жыл бұрын
Thanks helped a lot subscribed .
@dcode-software
@dcode-software 3 жыл бұрын
Awesome 🙂
@naiemofficial_
@naiemofficial_ 4 жыл бұрын
I did it successfully as your tutorial. I'm using it in a multi-step form. I want to hide the login form and show another module from php at that same file once $_POST data will match with php condition. Thanks in advance.
@Pengoled
@Pengoled 3 жыл бұрын
Hi, great tutorial. I am actually new to PHP and I am really confused about how to start writing in PHP? Which program do I need to install to get started? Thanks
@dcode-software
@dcode-software 3 жыл бұрын
My suggestion is to install something like XAMPP and WAMP - they provide easy installs for an Apache Web Server and PHP environment
@moisescastillo3447
@moisescastillo3447 6 жыл бұрын
awesome, videos like this with this level it helps a lot, I wonder if you can make a contact form with captcha, and button to update the recatcha, php ajax and native javascript, since it is appreciated for everything
@TheMrPopov
@TheMrPopov 5 жыл бұрын
You explained it very well, thanks!
@dcode-software
@dcode-software 5 жыл бұрын
Hey no problem!
@niko-sd5pv
@niko-sd5pv 5 жыл бұрын
For example im using linux with Chrome and is not working...
@saregama.devsaikat
@saregama.devsaikat Жыл бұрын
Thanks
@LoveAntifa
@LoveAntifa 4 жыл бұрын
My current dilemma is that the form works and sends the info to the mysql database but it's all in small letters even if I'm using caps lock, I want to be able to use small and capital letters so how do I accomplish it?
@abdurhmanalsobhi4564
@abdurhmanalsobhi4564 3 жыл бұрын
So no need to use header('content-type: application/json') in the php script ? is json_encode() just enough ?
@dcode-software
@dcode-software 3 жыл бұрын
Technically it'll do the job but it's very highly recommended you use content-type so the receiver knows what data type it's receiving. Please see my video on content-type for more info, it's definitely worth a watch
@galihridhoutomo
@galihridhoutomo 4 жыл бұрын
Sir i am using firebase and npm, this web not using PHP file, if you were me what would you do ?
@Lchends
@Lchends 5 жыл бұрын
Hi there, I'm very new to AJAX and JavaScript, and I wanted to know how do you run the page, like, don't you need a server? What is your 'youtube.web"?
@Lchends
@Lchends 5 жыл бұрын
Just found out :D I'm using the LAMP stack on Ubuntu, ty!
@shubhadas1537
@shubhadas1537 5 жыл бұрын
but u don't setup database for this
@andykyle9347
@andykyle9347 5 жыл бұрын
Sir how to encrypted form data while we send data through url using post/get method
@better_vet
@better_vet 5 жыл бұрын
I have one problem --> this check-login.php is going on post as an action to server and response with answer but I had another php file going on post action and I don't know how to merge this 2 different php file and make one file to say to server as post and get them to work too any Solution???
@windandkitesurfer
@windandkitesurfer 5 жыл бұрын
I follow step x step, a couple of times using your exact text - at 18:40 where your "console.log(requestData);" shows the actual values of the two input variables (username and password) I get this on the console (note same output on edge and chrome): username=${form.username.value}&password=${form.password.value} Within my script tags I am setting "requestData" here: const requestData = 'username=${form.username.value}&password=${form.password.value}'; ...and loading "form" here: const form = { username: document.getElementById('username'), password: document.getElementById('password'), submit: document.getElementById('btn-submit'), messages: document.getElementById('form-messages') }; Thanks, any feedback welcome!
@dcode-software
@dcode-software 5 жыл бұрын
You need to use back ticks: `
@windandkitesurfer
@windandkitesurfer 5 жыл бұрын
thank you @@dcode-software that was it! In all my years programming never used the ` key, first time and now I'll be wondering how I was able to not use it for so long. Thanks again, you have gained a loyal subscriber :)
@dcode-software
@dcode-software 5 жыл бұрын
No worries mate! Haha, just FYI it won't work in Internet Explorer :)
@windandkitesurfer
@windandkitesurfer 5 жыл бұрын
@@dcode-software, yes it will work in ALL browsers with just a few slight tweaks: I assign all values to the vars I plan on passing via ajax to the php processing page (note I'm using my own test form variables): let first_name = document.getElementById('first_name').value; let last_name = document.getElementById('last_name').value; let email = document.getElementById('email').value; let textarea1 = document.getElementById('textarea1').value; loading the requestData object as follows: const requestData = 'first_name='+first_name+'&last_name='+last_name+'&email='+email+'&textarea1='+textarea1; working perfectly in Chrome, Edge and ie11 Thank you again for helping along this path!!
@markystudio14
@markystudio14 3 жыл бұрын
That's the error that I encountered but when I check the code. I saw that (') this is not the right code there. So I just copy the back tick on sql server and paste it. Then worked. But I got a problem in a last part of this video about posting the error messages. It says Uncaught TypeError: cannot read property 'forEach' of undefiened
@romainpolo2133
@romainpolo2133 5 жыл бұрын
Thank you !
@dcode-software
@dcode-software 5 жыл бұрын
No problem mate!
@andykyle9347
@andykyle9347 4 жыл бұрын
hi sir did u have tutorial using simple database for ajax tutorial
@arofficialtv3727
@arofficialtv3727 3 жыл бұрын
Is the username and password is already set example the dcode?
@rahulps
@rahulps 4 жыл бұрын
please help i have issues when using mysqli functions in check-login.php error in console "could not parse json"
@Sparkly-1999
@Sparkly-1999 3 жыл бұрын
I have the same issue
@rahulps
@rahulps 3 жыл бұрын
@@Sparkly-1999 i fixed it somehow
@gayathrirejeesh2978
@gayathrirejeesh2978 2 жыл бұрын
@@rahulps how?
@rahulps
@rahulps 2 жыл бұрын
@@gayathrirejeesh2978 need to check it was an year ago
@gayathrirejeesh2978
@gayathrirejeesh2978 2 жыл бұрын
@@rahulps atleast where to find solution?
@BLOPIsUrM8
@BLOPIsUrM8 4 жыл бұрын
Can i Integrate this with django the same way?
@velikijrabochij7353
@velikijrabochij7353 4 жыл бұрын
Hello sir, I have question, I just watched the video and haven't tried to code it yet, but in the else statement you remove a firstChild which is already empty in the ul. My question is: Why you need to remove a firstChild if inside of a parentElement was already empty?
@yonathanhailemelekot5238
@yonathanhailemelekot5238 3 жыл бұрын
he does not want to append to the previous errors
@medooaattya9870
@medooaattya9870 4 жыл бұрын
thank you for this , i have problem when i try to get responseObj = JSON.parse(xhr.responseText) console log to me Unexpected token < in JSON at position 0 :(
@codecast8713
@codecast8713 3 жыл бұрын
You sound like Rowan from Viva La Dirt League.
@cdrrffrhrhr5279
@cdrrffrhrhr5279 4 жыл бұрын
Uncaught TypeError: Cannot read property 'firstChild' of null at handleResponse (index.html:72) at XMLHttpRequest.request.onload (index.html:55) 100% follow your code, the system reports an error. Could you please share me source code? i want to figure out why and learn, i am still a newbie of coding. Thank you for this tutorial anyway^_^
@wonjaehwang7670
@wonjaehwang7670 4 жыл бұрын
Thanks for video what keyboard do you use? The switches sound nice
@dcode-software
@dcode-software 4 жыл бұрын
No probs, the keyboard is MasterKeys Pro S RGB (Cherry MX Blue)
@jamesecroyd
@jamesecroyd 4 жыл бұрын
@@dcode-software same here chur for tuitorial mate
@riddhicalidas6113
@riddhicalidas6113 5 жыл бұрын
Hi, can you please post the CSS file with this tutorial; this is a great tutorial - best one for me.
@Dexter101x
@Dexter101x 3 жыл бұрын
Do you really need it???
@leslinks
@leslinks 4 жыл бұрын
if i use form tag instead of div, will the click fn work ?
@dcode-software
@dcode-software 4 жыл бұрын
Yeah definitely, it will work. Thanks for joining the live stream btw
@ca4990
@ca4990 5 жыл бұрын
I thought that in a registration format you need to use a database, to hash the password and then verify if its correct using PDO or mysqli...
@arminharper510
@arminharper510 4 жыл бұрын
there are different ways to do it. AJAX does the same thing. on your PHP script you can write code to retrieve data from MYSQL, compare it to the data sent by the client(javascript) then send a response, or save the data sent by the client and save it in MYSQL and send a success message back to the client (Javascript) the only difference is that with AJAX everything happens live, you see no loading, you will not be redirected to another page and don't need to refresh the page to see the messages. if you use a POST method form and click sign in, you will see that briefly the page refreshes to show you the server response, that is not the case, basically AJAX helps you build web apps that behave like desktop apps(everything happens live)
@raniamahmoud3165
@raniamahmoud3165 4 жыл бұрын
I have a problem with displaying the error messages, the console gives me a " Uncaught TypeError: Cannot read property 'forEach' of undefined at handleResponse at XMLHttpRequest.request.onload " everything else works just fine, even if I replaced the foreach loop within the "Handle response function" with a console message it gets displayed. can you help me with fixing that?
@muhammaddzakwan6783
@muhammaddzakwan6783 3 жыл бұрын
i have the same error...
@markystudio14
@markystudio14 3 жыл бұрын
I got that error too and I don't know what is wrong.
@markystudio14
@markystudio14 3 жыл бұрын
Any one who solved this problem ?
@DipesMandaviya
@DipesMandaviya 4 ай бұрын
where is source code?
@loganzenker122
@loganzenker122 4 жыл бұрын
Hey dcode! Thanks a lot for this tutorial! I am wondering if you know a way to bypass the CORS issue I seem to be having? Every time I submit the login, it says it has been blocked by CORS policy. Thank you for your time!
@dcode-software
@dcode-software 4 жыл бұрын
Hey, no probs! I've got this video on CORS if you wanna take a look at it, it should explain why you're getting that problem: kzbin.info/www/bejne/Znqwq2uabqiVr5Y
@zakariamarmoud7638
@zakariamarmoud7638 4 жыл бұрын
catch error ?? could not parse JSON i don't know why ?
@dcode-software
@dcode-software 4 жыл бұрын
Your JSON string is invalid, try validating it using an online tool maybe
@gayathrirejeesh2978
@gayathrirejeesh2978 2 жыл бұрын
did you get it?
@dopamine_Seeker
@dopamine_Seeker 3 жыл бұрын
not a secured way....
@danielesette1950
@danielesette1950 5 жыл бұрын
nice tutorial, but i can't get this code working. Every input in the login form pops out the errors "Password can not be empty!, Username can not be empty!" i don't really get whats wrong
@dcode-software
@dcode-software 5 жыл бұрын
Do you have a "name" attribute on the input fields?
@danielesette1950
@danielesette1950 5 жыл бұрын
@@dcode-software nope, i followed your guide. Did i miss something?
@dcode-software
@dcode-software 5 жыл бұрын
Are you saying "nope" that you didn't add a "name" attribute? If so then you need to add it. Without it the input won't be submitted to the server and that could explain why you're getting those messages
@danielesette1950
@danielesette1950 5 жыл бұрын
@@dcode-softwareI just did it, but nothing changed. Does the name need to be a specific string or something?
@dcode-software
@dcode-software 5 жыл бұрын
The fields need to be "username" and "password" respectively - if you upload your code to something like CodePen I can have a look at it for you.
@mdalamiri7400
@mdalamiri7400 6 жыл бұрын
Hi Dom , can you make another video , how to use ajax in django. please reply to me
@dcode-software
@dcode-software 6 жыл бұрын
Hey mate, are you referring to making an AJAX call to a Django-backed server?
@mdalamiri7400
@mdalamiri7400 6 жыл бұрын
Yes , if you know django.
@dcode-software
@dcode-software 6 жыл бұрын
I haven't had much exposure at all to Django but it is something that I'd be open to making a video about - but if you wanted to make an AJAX call the process wouldn't be too different any other server, you'd simply set up some sort of endpoint or API and then make the request!
@mdalamiri7400
@mdalamiri7400 6 жыл бұрын
I am using django and recently start to learn ajax call in javascript but I didn't find a lot of tuts to learn it in javascript, so I had to learn jquery , after that ajax, so learned jquery and now I start to learn Ajax. but I have this trouble . which is (there are not enough videos to learn ajax call using django). but anyway thank you for your time ... you are awesome man ... continue in this way.... someday you will be something great.
@dcode-software
@dcode-software 6 жыл бұрын
Thanks very much I appreciate the support man 😁
@Henry_Nunez
@Henry_Nunez 2 жыл бұрын
👏
@JoshuaTMagee
@JoshuaTMagee 4 жыл бұрын
Fantastic tutorial, thank you! I'm curious how you would go about taking the JSON response from the server and display each error message directly underneath each relevant form input field? So, for example, any email form errors are displayed underneath the email input field, etc. Essentially, how would you integrate the code from this tutorial into a UX design like the one in this other tutorial of yours: kzbin.info/www/bejne/bH_HiKWQbJyMhZY Thank you so much!
@musiclovers8488
@musiclovers8488 4 жыл бұрын
Hello sir !! There isn’t any short way?
@kartikdesai597
@kartikdesai597 3 жыл бұрын
Don😎
@dcode-software
@dcode-software 3 жыл бұрын
DOM*
@danbrown5080
@danbrown5080 5 жыл бұрын
Can I have ur email?
@dcode-software
@dcode-software 5 жыл бұрын
What for?
@danbrown5080
@danbrown5080 5 жыл бұрын
@@dcode-software I have some problem in mvc
@dcode-software
@dcode-software 5 жыл бұрын
Hey man send it to me on twitter, or just post it here
@danbrown5080
@danbrown5080 5 жыл бұрын
my first problem is register and login in mvc.I download 10-12 vids but they aren't what i want
5: How to validate a form using AJAX - Learn AJAX programming
35:27
Dani Krossing
Рет қаралды 191 М.
Async JavaScript Part 1: What is AJAX?
21:25
Code with Ania Kubów
Рет қаралды 120 М.
Amazing Parenting Hacks! 👶✨ #ParentingTips #LifeHacks
00:18
Snack Chat
Рет қаралды 19 МЛН
Teaching a Toddler Household Habits: Diaper Disposal & Potty Training #shorts
00:16
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 21 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 6 МЛН
JSON and AJAX Tutorial: With Real Examples
40:45
LearnWebCode
Рет қаралды 1,8 МЛН
Submit form with ajax and store data into database
15:54
Coder Anindya
Рет қаралды 23 М.
ajax with javascript malayalam detailed tutorial
47:12
Tintu Vlogger
Рет қаралды 24 М.
The "submit" event on forms in JavaScript
8:51
dcode
Рет қаралды 115 М.
JavaScript Client-side Form Validation
29:07
Florin Pop
Рет қаралды 714 М.
Amazing Parenting Hacks! 👶✨ #ParentingTips #LifeHacks
00:18
Snack Chat
Рет қаралды 19 МЛН