Server IP : 162.240.98.243 / Your IP : 3.129.210.91 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/www/login.easenup.in/ |
Upload File : |
<!DOCTYPE html> <html> <head> <style> .container { display: flex; flex-direction: column; align-items: center; justify-content: center; } h1 { color: green; } h3 { text-align: center; } input, span { margin-top: 20px; } </style> </head> <body> <div> <h1 class="container"> GeeksforGeeks </h1> <h3>Submitting the form without page refresh</h3> </div> <form> <div class="container"> <input placeholder="Name" type="text" name="Name" /> <input placeholder="Job" type="text" name="job" /> <input type="submit" /> </div> <span class="container"></span> </form> <script src= "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"> </script> <script type="text/javascript"> $(document).ready(function() { $('form').on('submit', function(event) { event.preventDefault(); // It returns a array of object let userinfo = $(this).serializeArray(); let user = {}; userinfo.forEach((value) => { // Dynamically create an object user[value.name] = value.value; }); let url = "https://reqres.in/api/users"; $.ajax({ method: "POST", url: url, data: user }).done(function(msg) { // When the request is successful $('span').text('user is successfully created with Id ' + msg.id); }).fail(function(err, textstatus, error) { $('span').text(textstatus); }); }); }); </script> </body> </html>