Reputation: 361
I have a form that lets a user select a list of courses, upon selection the value equals a course code 111 for instance. I can update a variable in a php graph generating file through AJAX with this selection.... the trouble is that i need to refresh or reload these images dynamically. i display the images like so;
<?php
for ($i = 1; $i < 39; $i++)
{
$sqlquestion = 'SELECT Question FROM tquestion WHERE QuestionID = '.$i.'';
$questiontext = mysql_query($sqlquestion,$odbc) or die ("can not run query");
$q = mysql_fetch_row($questiontext);
?>
<div id="bars"><img src="bars.php?graph=<?php echo $i;?>"></div>
<?php
}
this loop provides me with 38 graphs (one for each question from a survey)
I am stuck how to redisplay these graphs once the variable has been changed.
I hope I've made sence any help would be greatly appreciated :) Thanks
Upvotes: 0
Views: 204
Reputation: 745
After your ajax request success add code below at the end of your success function.
$('#bars img').attr("src", "path/to/new/image.jpg"); // replace path with your image path
if you use jQuery ajax this code should be at end of success function, as below
$.ajax({
success: function(){
// but the code at end of this function
},
});
I hope this help
Upvotes: 1