MyBB Community Forums

Full Version: Jquery Help please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

currently I have this code for my ajax form submission

$(function(){
	$('#ajax_form').submit(function(e){
		e.preventDefault();
		var form = $(this);
		var post_url = form.attr('action');
		var post_data = form.serialize();
		$('#loader', form).html('<img src="loader.gif" /> Please Wait...');
		$.ajax({
			type: 'POST',
			url: post_url, 
			data: post_data,
			success: function(msg) {
				$(form).fadeOut(200, function(){
					form.html(msg).fadeIn().fadeOut(1000);
				});				
			}
		});
	});
});

But I then want to fade in my form again is this possible or to have a link to ask submit again? This all must take place without refreshing due to an applet running next to it. Currently it fades the the form out then fades in the message Error/Success but then I want the form in that as well :/.

Is it possible and if so could you help me, I really don't know ajax at all :s
My form is below

    <form action="process.php" method="post" id="ajax_form">
    <div class="right">
		<div class="top"></div>
        <div class="mid">
        	<div class="form">
                <span class="head">Report a Bug</span>
                <p class="stuff"><input type="text" name="title" value="Enter a title"></p>
                <p class="stuff"><textarea cols="35" rows="15" name="bug">Enter your bug report here</textarea></p>
                <p class="stuff"><div id="loader"><input type="submit" id="submit" /></div>
            </div>
        </div>
        <div class="bot"></div>    
    </div>
    </form>

Thanks in advance. Also when I tried to fade it back in when I clicked the submit button it didn't do any ajax it just went to process.php :/