I have thought that:
$('#slideshow_body').html(newContent);
would be equivalent to this:
document.getElementById('slideshow_body').innerHTML=newContent;
But it is not. Only the latter of the two works =( I was looking to modernize and shorten my code a bit.
newContent contains this string at the moment, but will hold any number of div:s:
<script id="pauseTimesScript" type="text/javascript">
//<![CDATA[
/* Define pauseTimes (array holding duration of each slide) */
try {
pauseTimes=null;
pauseTimes=undefined;
pauseTimes = new Array();
setPauseTimes();
/*alert('satte först till null, deklarerade sedan om.');*/
} catch(e) {
pauseTimes = new Array();
setPauseTimes();
/*alert('deklarerade utan att först sätta null.');*/
}
function setPauseTimes() {
pauseTimes[1]=10000;
}
//]]>
</script>
<div id="avbrott" style="display: none;">
Tillfälligt avbrott, visar cachelagrat innehåll sedan
2012-10-31 14:04:52
</div>
<div id="canvas" style="width:1072px;height:732px;">
<div id="slide1" class="slide" style="z-index: 1; display: block;">
<div id="slide_bg" style=
"float:left;height:100%;width:100%;background-color:#ffffff;background-image:url('http://bglabs.evade.netdna-cdn.com/45875kli90/71.jpg');">
<div style=
"background-color:#ff0000;color:#ffffff;float:none;text-align:center;margin-top:30px;padding:10px;font-weight:bold;font-size:58pt;"
id="preview_title">
Nu är det jul igen!
</div>
<div style="clear:both;float:none;"></div>
<p style=
"color:#0f00de;margin:10px 10px 0 20px;font-style:italic;font-size:42pt;" id=
"preview_data_6">Tja, snart i alla fall =)</p>
</div>
</div>
</div>
Here is how I obtain that string, don't know if it changes anything...
function ajaxUpdate() {
//Load current uri again asynchroneously
var jqxhr = $.get(currentUri)
.success(function(data) { newContent = data; })
.error(function() { newContent = 'blank'; });
//make sure we got the end token (</body>) so that our transmission wasn't interrupted in the middle of the request
endtoken_test = newContent.search('</body>');
//strip of everything before starttoken (<body>)
newContent = newContent.substring(newContent.indexOf('<body id="slideshow_body">') +26 );
//strip of everything before endtoken (</body>)
newContent = newContent.slice(0, newContent.lastIndexOf("</body>"));
if (endtoken_test != -1) {