Link to home
Start Free TrialLog in
Avatar of evibesmusic
evibesmusicFlag for United States of America

asked on

jQuery dialog shows dynamic content in IE8 once, then does not refresh upon dialog or page reload?

Experts,

I've created a link on my page which opens a jQuery dialog. Within this dialog is a simple form which has one textarea and a submit button.

Content from the DB is placed into the textarea so that it can be edited. When the form is submitted, the DB is updated and the page is refreshed.

In all other browsers except IE8, the dialog pulls the latest data from the DB each time the dialog is opened regardless if the form was submitted and the page was refreshed.

In IE8, when the dialog  is opened the first time, it queries the DB and shows the information as expected. If the dialog is closed and then reopened again, it doesn't fetch the latest results from the DB, it simply shows the same information again.

This happens even if the page is refreshed because the user submitted the form?

In my jQuery code there is code to empty the dialog so I am not sure why IE8 differs from other browsers (FF, Safari, etc.)?

Here's my jQuery code:
	<script>
	$(function() {         
		  $(".modal_link").click(function(e) {
				e.preventDefault();
				var url = $(this).attr("href");
			    var mytitle = $(this).attr("title");
				$("#dialog").load(url,null,function() {
					  $("#dialog").dialog({
						    title: mytitle,
							width:700,
							modal: true,
							close: function(event, ui) {
							$("#dialog").empty(); // remove the content 
							}//END CLOSE
					  });//END DIALOG
				});//END DIALOG
		  });//END MODAL_LINK
	});//END FUNCTION
	</script>

Open in new window


Here is a sample link which opens the jQuery dialog:
echo'<a class="modal_link" title="'.$edit_result['project_title'].' - Progress Notes" href="../scripts/a3_dialog_content.php?cmd=notes&a3_id='.$edit_result['id'].'">';

Open in new window


Here is my PHP code which creates the dialog content:
if($_GET['cmd']=='notes'){
	$a3_id = $_GET['a3_id'];
	$notes_sql = "SELECT * FROM a3_progress_notes WHERE a3_id='".$a3_id."'";
	$notes_query = mysql_query($notes_sql) or die ("Could not run query: " . $notes_sql . "<br />\n" . mysql_error () );
	$notes = mysql_fetch_array($notes_query);
	echo'<form action="'.$_SERVER['PHP_SELF'].'?cmd=update_notes&a3_id='.$a3_id.'" method="post" name="update_notes">';
		echo'<textarea name="notes" class="search_box" style="width:96%; min-height:100px;">'.$notes['notes'].'</textarea>';
		echo'<div>';
			echo'<div style="float:left; padding-top:10px;">';
				echo'<span style="font-variant:small-caps">Last Updated: '.date('m-d-Y @ g:i A',strtotime($notes['updated_on'])).'</span>';
			echo'</div>';
			echo'<div style="float:right;">';
			echo'<input type="image" src="../images/save.png" title="Save" style="margin-top:10px;" height="30px" width="30px" />';
			echo'</div>';
		echo'</div>';
		echo'<input type="hidden" value="'.$a3_id.'" name="a3_id" />';
	echo'</form>';
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nap0leon
nap0leon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of evibesmusic

ASKER

@All:

Thank you for suggestion of the random number. When I place the random number in the form's action code nothing changed.

When I placed the randomized number within the link which opens the dialog I now am getting the latest values in the DB.

Issue fixed!

Thanks Experts!

Updated hyperlink code:
$x = rand(100000, 999999);
echo'<a class="modal_link" title="'.$edit_result['project_title'].' - Progress Notes" href="../scripts/a3_dialog_content.php?cmd=notes&a3_id='.$edit_result['id'].'&x='.$x.'">';

Open in new window

See my last post for solution.

Thanks Experts!