JQuery AJAX ShoutBox
How do I make an jquery ajax shoutbox?
A simple shoutbox that uses jQuery and AJAX to update a mySQL database via jQuery .get() and PHP.. What is a jquery ajax shoutbox? How do you make a jquery ajax shoutbox? This script and codes were developed by Tim Ivey on 26 September 2022, Monday.
JQuery AJAX ShoutBox - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>jQuery AJAX ShoutBox</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="container"> <header> <h1>JS Shoutbox</h1> <p>Give me a shoutout!</p> </header> <div id="shouts"> <ul> <li></li> </ul> </div> <footer> <form> <label>Name: </label> <input type="text" id="name"> <label>Shout text: </label> <input type="text" id="shout"> <input type="submit" id="submit" value="shout!"> </form> </footer>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
JQuery AJAX ShoutBox - Script Codes CSS Codes
body { font-family: arial, sans-serif; background: #000; color: #fff; font-size: 14px;
}
#container { width: 700px; margin: 40px auto; overflow: auto; border: 1px solid #ccc;
}
header { background: #333; padding: 10px; text-aligh: center;
}
#shouts { height: 150px; border: #333 1px solid; margin: 30px; padding: 15px; overflow-y: scroll;
}
#shouts li { list-style: none; line-height: 1.7em;
}
footer { padding: 10px; background: #333; text-align: center;
}
input#name,
input#shout { padding: 3px; height: 15px;
}
input#name { width: 130px; margin-right: 20px;
}
input#shout { width: 170px; margin-right: 20px;
}
input#submit { padding: 5px 10px; border: 0; background: #666; color: #fff; cursor: pointer;
}
JQuery AJAX ShoutBox - Script Codes JS Codes
$(document).ready( function() { // populate shouts $( "#shouts ul" ).load( "http://timivey.com/external/codepen/shoutbox/load_shouts.php" ); // Put mouse focus on name $('#name').focus(); // submit handler $('#submit').on('click', function(e) { e.preventDefault(); var name = $('#name').val(); var shout = $('#shout').val(); var dataString = 'name=' + name + '&shout=' + shout; // validation if ( name == '' || shout == '' ) { alert('Please fill in your name and shout'); } else { $.ajax({ type: 'post', url: 'http://timivey.com/external/codepen/shoutbox/shoutbox.php', data: dataString, cache: false, success: function(html) { console.log(html); $('#shouts ul').prepend(html); } }); } // erase shout message $('#shout').val('').focus(); });
});
Developer | Tim Ivey |
Username | timivey |
Uploaded | September 26, 2022 |
Rating | 3 |
Size | 2,469 Kb |
Views | 78,936 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
AngularJS Dependency Injection | 1,737 Kb |
Javascript Closures | 1,573 Kb |
JavaScript Methods | 1,500 Kb |
Recursion | 1,453 Kb |
Simple JQuery Content Slider | 2,904 Kb |
Load JSON via Codepen | 1,506 Kb |
Elementary JavaScript quiz form | 2,613 Kb |
IIFE | 2,433 Kb |
JQuery FAQ Accordion | 2,601 Kb |
Higher-order functions | 1,687 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Horizontal slider on scroll | Alojzije | 2,672 Kb |
Highbrow Basic HTML Lesson 8 | Kimlarocca | 2,094 Kb |
Webkit decolorize | Fivera | 1,675 Kb |
Drag and Drop Quiz | Cgspicer | 3,837 Kb |
Count checked checkboxes with jQuery | Mestika | 2,343 Kb |
TigerWoods Freecodecamp Page | Baileytj | 2,869 Kb |
JS Beispiel getElementsByClassName 3 | HSZG-Frontend-Kurs | 1,988 Kb |
Scrolling Horizontal Isotope | Bramus | 2,017 Kb |
React Vote Component | Souporserious | 5,465 Kb |
Search field | Jamesbarnett | 2,100 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!