Jump to content

Reload Div After Successfully Php Script On Other Page


davidb52

Recommended Posts

<script type="text/javascript">$(document).ready(function(){$("#form1").submit(function(e){//prevent default form submit action and prevent page reloade.preventDefault();$.ajax({	type: "POST",	url: "process.php",	data: $('#form1').serialize() ,success: function (html) {$('#test').fadeOut("slow").load(html).fadeIn("slow");	},	error: function (x, e) {		if (x.status === 0) {			alert("You are offline.\n Please Check Your Network Connection Status.");		} else {			if (x.status == 404) {				alert("Your document was not sent due to an error - 404.\n\nPlease report this issue to the NSMC IS Helpdesk");			} else {				if (x.status == 500) {					alert("Internal Server Error #500 has occured.");				} else {					if (e == "parsererror") {						alert("Error.\nParsing JSON Request failed.");					} else {						if (e == "timeout") {							alert("Request Time out. You may need to reload the page and try again.");						} else {							alert("Unknown Error.\n" + x.responseText);						}					}				}			}		}	}});});});</script>

It's working it fade out and fade in but doesn't really refresh the div test. How could I refresh div test? I think I need some ajax but how?here's what is in div test:

<div id="test"><?php$query = mysql_query("SELECT p.dbunique,p.usersid,p.ido,p.message,p.time,u.firstname,u.lastname,u.easyname,u.id FROM usersppm as p,users as u WHERE p.usersid='" . mysql_real_escape_string( $ido ) . "' and u.id=p.ido ORDER BY p.time DESC LIMIT 0,10");if(isset($_GET['p'])){   if($_GET['p']<=0){   $query = mysql_query("SELECT p.dbunique,p.usersid,p.ido,p.message,p.time,u.firstname,u.lastname,u.easyname,u.id FROM usersppm as p,users as u WHERE p.usersid='" . mysql_real_escape_string( $ido ) . "' and u.id=p.ido ORDER BY p.time DESC LIMIT 0,10");	}	else{	$limit = $_GET['p'] - 1;	$limit = $limit * 10;	$query = mysql_query("SELECT p.dbunique,p.usersid,p.ido,p.message,p.time,u.firstname,u.lastname,u.easyname,u.id FROM usersppm as p,users as u WHERE p.usersid='" . mysql_real_escape_string( $ido ) . "' and u.id=p.ido ORDER BY p.time DESC LIMIT " . mysql_real_escape_string( $limit ) . ",10");}}while($row1 = mysql_fetch_assoc($query)){$dbunique = $row1['dbunique'];$usersid = $row1['usersid'];$ido2 = $row1['ido'];$message = htmlentities($row1['message'], ENT_QUOTES, "UTF-8" );$time = $row1['time'];$firstnameo = htmlentities($row1['firstname'], ENT_QUOTES, "UTF-8" );$lastnameo = htmlentities($row1['lastname'], ENT_QUOTES, "UTF-8" );$easyname = htmlentities($row1['easyname'], ENT_QUOTES, "UTF-8" );$query2 = mysql_query("SELECT profilepic,profilen FROM userspp WHERE id='" . mysql_real_escape_string( $ido2 ) . "'");while($row2 = mysql_fetch_assoc($query2)){$profilepic = htmlentities($row2['profilepic'], ENT_QUOTES, "UTF-8" );$profilen = htmlentities($row2['profilen'], ENT_QUOTES, "UTF-8" );}?><div id="ppmmfull"><?phpif(mysql_num_rows($query2)){list($width, $height) = getimagesize($profilepic);if($width>$height){ $width = 'ok';?><a style="color: white;" href="profile.php?n=<?php echo $easyname; ?>"><img style='float: left; margin:0px 5px 0px 5px;' src="<?php echo $profilepic; ?>" alt="profile picture" height="80px" width="80px" title="<?php echo $profilen; ?>"></img></a><?php  }else{ ?><a style="color: white;" href="profile.php?n=<?php echo $easyname; ?>"><img style='float: left; margin:0px 5px 0px 5px;' src="<?php echo $profilepic; ?>" alt="profile picture" height="80px" width="80px" title="<?php echo $profilen; ?>"></img></a><?php}}else{ ?><img style='float: left;' src="../images/noprofilepic.png" alt="profile picture" height="80px" width="80px" title="no profile picture"></img><?php } ?><a href="profile.php?n=<?php echo $easyname; ?>"><?php echo '' . $firstnameo . ' ' . $lastnameo . ''; ?></a> <span style='margin-left: 5px; font-size: 10px;color: grey;'><?php if($_SESSION['or']==1){ $time = $time + $_SESSION['timezone'] + $_SESSION['summertime'];} else { $time = $time - $_SESSION['timezone'] + $_SESSION['summertime'];} echo date("d-m H:i",$time ); ?> <?php if($ido2==$id or $id==$ido){ ?> <a href="profile.php?dm=<?php echo $dbunique; ?>&n=<?php echo $name; ?>">Delete</a> <?php } ?></span><div id='ppmm' style="min-height:80px;"><?php$message = preg_replace("#((http|https|ftp)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie","'<a href=\"$1\" target=\"_blank\">$3</a>$4'",$message); echo $message;?></div></div><?php  } ?><?php$pagenation = mysql_query("SELECT dbunique FROM usersppm WHERE usersid='".mysql_real_escape_string( $ido )."'");$count = mysql_num_rows($pagenation);if(isset($_GET['p']) and $_GET['p']>1){ ?><a href='profile.php?p=<?php $page = $_GET['p']-1; echo $page;?><?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>Back</a><?php}if($count>1){?><a href='profile.php?p=1<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>1</a><?php}if($count>10){ ?><a href='profile.php?p=2<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>2</a><?php}if($count>20){?><a href='profile.php?p=3<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>3</a><?php}if($count>30){ ?><a href='profile.php?p=4<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>4</a><?php}if($count>40){?><a href='profile.php?p=5<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>5</a><?php}if($count>50){ ?><a href='profile.php?p=6<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>6</a><?php}if($count>60){?><a href='profile.php?p=7<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>7</a><?php}if($count>70){ ?><a href='profile.php?p=8<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>8</a><?php}if($count>80){?><a href='profile.php?p=9<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>9</a><?php}if($count>90){ ?><a href='profile.php?p=10<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>10</a><?php}if($count>100){?><a href='profile.php?p=11<?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>11</a><?php}?><a href='profile.php?p=<?php if(isset($_GET['p'])){ $page = $_GET['p']+1; echo $page; }else{ echo '2'; }?><?php if(isset($_GET['n'])){ $name = $_GET['n']; echo  "&n=$name"; } ?>'>Next</a></div>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...