JQuery AJAX ShoutBox

Developer
Size
2,469 Kb
Views
78,936

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 Previews

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(); });
});
JQuery AJAX ShoutBox - Script Codes
JQuery AJAX ShoutBox - Script Codes
Home Page Home
Developer Tim Ivey
Username timivey
Uploaded September 26, 2022
Rating 3
Size 2,469 Kb
Views 78,936
Do you need developer help for JQuery AJAX ShoutBox?

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!

Tim Ivey (timivey) Script Codes
Create amazing blog posts with AI!

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!