You can : 1. wrap the submit callback in a method and give it to eat to the form each time you receive it again 2. put the form somewhere else so it's not changed by the ajax call when you reload and the submit stays attached 3. use .livequery() <http://docs.jquery.com/Plugins/livequery/livequery>(sadly .live() doesn't work with submit events)
As for me I'd rather use the 2nd method when possible because it's really simpler and requires less voodoo, the 3rd probably being the best in most complicated cases, and the 1st being simple as long as you don't have 2 or more criss-crossing ajax calls that may change the page in different ways. Hope it helps. Michel Belleville 2009/11/10 Dominik Kohlstruck <o...@hotmail.de> > Does noone have a solution to this...? > > Hey guys, I'm working on a "status"-Updater. It works, there is just > one problem, after sending a Status I have to manual reload the page > to let the script work again. Do you can help me please? Here's the > code: > > <script language="javascript"> > $(document).ready(function(){ > $("form#status_form").submit(function(){ > var s_autor = $('#s_autor').attr('value'); > var s_status = $('#s_status').attr('value'); > $.ajax({ > type: "POST", > url: "/admin/request.php", > data: "s_autor="+ s_autor +"& s_status="+ s_status, > success: function(){ > $('#show').load("/admin/request.php").fadeIn > ("slow", function(){ > setTimeout(function(){ > $(function() { > $("#show").fadeTo > ("slow", 0.01, function(){ > $ > (this).slideUp("slow", function() { > $ > (this).remove(); > }); > }); > }); > }, 2000); > }); > }, > }); > return false; > }); > }); > </script> > > So do you know how to code it to make it possible to repeat the script > how often I click on the submit button? > > By the way, here's the HTML-Form: > > <form id="status_form" method="post" action="request.php" > onsubmit="return false;"> > <input type="text" id="s_autor" name="s_autor" value="<?= > $user_id; ?>" style="display: none;" /><input type="text" > id="s_status" name="s_status" value="Statusnachricht" /><input > type="submit" value="" class="submit" id="status_submit" /> > </form> > > Well, the file "request.php" is looking like this (in the moment!): > <div class="inhalt"><div class="text">Erfolgreich eingetragen!</div></ > div> The PHP-Part is coming up. I want to reach that if I click on the > submit-Button, the jquery-code works. Well, it works, but just ONE > TIME. After clicking the first time on the submit-button, the script > SHOULD work like it did the first time. But if I click on the submit > button the second time, nothing works. Anyway: I want the script work > as often I click on the submit button.... Hope you understand me. My > english is not the best... (I'm german...) >