...

View Full Version : POST form input on a <li>



Nightcrawler89
08-19-2011, 05:08 AM
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:

<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:


<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 ? =\

Old Pedant
08-19-2011, 05:27 AM
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.

Nightcrawler89
08-19-2011, 06:06 AM
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 ....

Old Pedant
08-19-2011, 06:39 AM
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.

Nightcrawler89
08-19-2011, 06:52 AM
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.

Old Pedant
08-19-2011, 06:55 AM
Might want to start here:

http://www.w3schools.com/php/php_ajax_intro.asp

Nightcrawler89
08-19-2011, 08:03 AM
Might want to start here:

http://www.w3schools.com/php/php_ajax_intro.asp

hahaha, thanks !!!!! =) .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum