Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <li>hello</li>
- <li id="formItem">
- <form action="" method="post">
- <input type=text name="content"/>
- </form>
- </li>
- <li>world</li>
- </ul>
- $("form").submit(function() {
- var inputText = $("input").val();
- $.ajax({
- type: "POST",
- url: "add.php",
- data: inputText,
- success: function() {
- $('#formItem').prev().after(
- "<li>" + inputText + "</li>"
- )}
- });
- });
- <?php
- $base = new PDO('sqlite:todo.db');
- $sql = $base->prepare("INSERT INTO ThisTable (content, priority) VALUES ('lolololol', 1);");
- $sql->execute();
- $base = null;
- ?>
- $('#yourForm').bind('submit', function (event) {
- jQuery.get('/ajax/interact.php', 'a=1&b=2', function (response) {
- alert("AJAX request succeeded, response from the server was: " + response);
- });
- event.preventDefault();
- });
- $('form.ajax').live('submit', function (event) {
- var self = $(this);
- jQuery[(self.attr('method') || 'get').toLowerCase()](self.attr('action'), self.serialize(), function (response) {
- alert("AJAX request succeeded, response from the server was: " + response);
- });
- event.preventDefault();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement