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>
It looks like after your first time calling this code, you are destroying #show, and thus, the next time, there is no more #show? I’m going to add some comments to your code to see if i’m understanding this correctly:
Good luck!
EDIT Upon looking at this some more, I noticed you are creating a document “ready” event after your setTimeout?
I’m trying to figure out the effect you want. It looks like you want to have something fade in after the upload finishes (in the
#showdiv), wait a few seconds, then fade it out again? (YourslideUpis acting on a faded-out element, so the effect won’t be seen.)How about something like this?