Let's say initially I have an image loaded in my view. Every now and then, I want that image to change via ajax with an interval of 10 sec. How can I do that? Thanks.
You can use the setTimeout command in javascript to do a jQuery postback and bring back the new image and render that to your control
Through setInterval()
.
Something like this,
var newimage = ['../image0.gif','../image1.gif','../image2.gif',
'../image3.gif','../image4.gif'];
setInterval(function(){
$('#imgID').attr('src',newimage[Math.floor(Math.random()*newimage.length)]);
// this will give you random images, but you can also not random it..
},10000);
html like this,
<img src="image0.gif" alt="image" id="imgID" />
use reigel's code and from the server return simple the image path. then load that path as the attribute 'src' of the image using jquery or anyway other way you know. need more clarity?
Use jquery plugin http://www.protofunc.com/scripts/jquery/ajaxManager3/ This plugin is compatible with jQuery current version 1.4.x.