i can't figure this out, it was working fine before, and i did a few updates
and now it only works when the button is pressed but not if i type into the form and press 'enter'.
i don't want he page to reload at all.
(also the entire wrapper for my page is hidden using css,
a loading image is displayed until the onload event fires,
then the wrapper uses jQuery's .slideDown(2000), so if javascript
is off they won't even see the form, i'm not concerned about
browsers with javascript disabled, i *only* want them to be able
to type in the field and hit enter or click the send button to
post the data via ajax with no page reload. i'll make it more accessible
later)
please help, this is driving me nuts, lol.
my html code looks like this...
my external .js file that deals with this form looks like this...Code:<form name="invbox" action=""> <span>Invite:</span> <input type="text" id="email" name="email" size="35" value="enter your friend's email here and press enter to send invite"> <input class="button" type="submit" value="Send"> <input type="hidden" id="user" name="user" value="nickname"> </form>
Code:/* invite handler */ $(".button").click(function() { var email = $("input#email").val(); var user = $("input#user").val(); if ( email == "" || user == "" ) { return false; } var datastring = 'email=' + email + '&user=' + user; $.ajax({ type: "POST", url: "invite.php", data: datastring, success: function() { $("input#email").val("Invitation Sent!"); } }); return false; });


Reply With Quote
Bookmarks