Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    POST form input on a <li>

    Allright, so i got index html, and on the head of the document i got jquery already, and what i got is a form, and what i want it to do is that once the input is sumbmited, to post it on a list. BUt something is missing here or maybe im doing it wrong, i need some guidance plz.

    here is my table:
    Code:
    <form name="postbar_add_post" id="postbar_add_post" method="post">
    	<fieldset>
        	<legend>Write text here ...</legend>
            <input type="text" name="addcontentbox" id="addcontentbox"  />
            <input type="button" name="addpost" value="Submit" class="submit" />
    	</fieldset>
    </form>
    and heres is the function that i have on the head, where what i try is to make it post on the list:

    Code:
    <script type="text/javascript">
    $(document).ready(function(){
    $("form#postbar_add_post").submit(function() {
    
    var message_wall = $('#addcontentbox').attr('value');
    
    $.ajax({
    type: "POST",
    data:"addcontentbox="+ addcontentbox,
    success: function(){
    $("ul#wall").prepend("<li>"+addcontentbox+"</li>");
    $("ul#wall li:first").fadeIn();
    }
    });
    return false;
    });
    });
    </script>

    But is just not working :S .... any ideas/guidance? xD .

    Btw, on the body, theres only that table above, and a " <ul id="wall"></ul> " , wich is where im trying the content to be posted on.

    Any ideas where the flaw is ? =\

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,032
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    Well, not to ask a silly question, but...

    Where are you telling AJAX what URL to post the information to???

    I don't see a URL anywhere in there.

    I don't use jQuery, but no matter what it can't post anything without a URL to post to.

  • #3
    New Coder
    Join Date
    Aug 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Well, not to ask a silly question, but...

    Where are you telling AJAX what URL to post the information to???

    I don't see a URL anywhere in there.

    I don't use jQuery, but no matter what it can't post anything without a URL to post to.
    lol,good question, thanks.

    ....I just have to see now how would i go about putting an url to the list ....

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,032
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    You're going to need a database on the server and then some sort of server-side code to handle the AJAX request: PHP or ASP or JSP or ...

    You can add content to "wall" from hitting the submit button, but it will only be on that page for that user, without the server side processing.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Aug 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I might use php thenn.

    THANKS !!!! I really needed the guidance xD. Makes more sence now xD.


    If anyone has more suggestions they're welcome =P.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,032
    Thanks
    75
    Thanked 4,325 Times in 4,291 Posts
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Aug 2011
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    hahaha, thanks !!!!! =) .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •