0

hi! I have problem with my jquery validation. When I successfully submitted my form, the value i enter is still there in the <input:text>. It supposed to be refresh and the form is emptied.

here's my jquery code

// JavaScript Document
	 $(document).ready(function(){
	 
	 $("#myformcom").submit(function(){
	 		
			var str=$(this).serialize();
			//var result;
			
			$.ajax({
			type: "POST",
			url: "submitcomment.php",
			data: str,
			success:function(msg)
			{
			
				$("#error").ajaxComplete(function(event,request,settings)
				{
				
					if(msg=='Successfully Submitted')
						{
							$(this).html(msg);
														
						}
					else{
							$(this).html(msg);
						}
						
					
						return true;			
				});
				
			}	
			});
			
			return false;
	 });
	 });

how can i refresh my page when it is successful?

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by canterorist
0

Is there a reason you want to refresh the page, or do you just want to clear the inputs ? You can use jquery do do it.

$('input').each(function() { $(this).val(''); });
0

hi! the code that you gave me was not working. i try it yesterday. the same result, the value is still there.

0

hi! your previous code that you give is now working. thanks to you. The reason why it didn't work in my first attempt because of the space in my submitcomment.php file. Thank you very much

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.