Forums

ASP

This topic is locked

MP3 Player With AJAX?

Posted 04 Mar 2008 02:35:18
1
has voted
04 Mar 2008 02:35:18 billy flynt posted:
Rendering the MP3 Player by updating the InnerHtml of a container does not work.

Is there a sample for using the MP3 Player in an ajax situation?

Thanks.

Replies

Replied 04 Mar 2008 23:15:27
04 Mar 2008 23:15:27 billy flynt replied:
Patrick W.,

You are right, just adding the MP3 Player SCRIPT via innerHTML does not work, e.g. does not execute the SCRIPT.

I have found a (bad) way to exec the MP3 Player SCRIPT block using 'eval' after updating the innerHtml of the target div block in AJAX call.

This is working, but not acceptable as a coding practice to utilize 'eval' in our project.

Can DMXzone.com provide a solution that does not require the 'eval' approach. I really need to get the MP3 Player working in a secure manner.

OLD FUNCTION:
function setDocSectionArticleReview(url,id) {
var callback = function(result) {
document.getElementById(id).innerHTML = result;
}
processArticleCategoryReview(url, callback);
}

NEW FUNCTION (using eval to exec the MP3 Player SCRIPT):
function setDocSectionArticleReview(url,id) {
var callback = function(result) {

var divId = document.getElementById(id);
divId.innerHTML = result;
var x = divId.getElementsByTagName("script";
for(var i=0;i<x.length;i++)
{
eval(x[i].text);
}

}
processArticleCategoryReview(url, callback);
}

Thanks.
Replied 05 Mar 2008 02:08:24
05 Mar 2008 02:08:24 billy flynt replied:
Changed the function to this, and the MP3 Player SCRIPT is executed without using 'eval'.

function setDocSectionArticleReview(url,id) {
var callback = function(result) {

var divId = document.getElementById(id);
divId.innerHTML = result;
var x = divId.getElementsByTagName("script";
var h = document.getElementsByTagName("head"[0];
for(var i=0;i<x.length;i++)
{
var s = document.createElement("script";
s.type="text/javascript";
h.appendChild(s);
s.text=x[i].text;
}

}
processArticleCategoryReview(url, callback);
}
Replied 05 Mar 2008 02:10:44
05 Mar 2008 02:10:44 billy flynt replied:
The above function works in IE, FF and SAFARI.

Maybe dmxzone.com could add an improved ajax sample for the MP3 Player, deflect some questions, save developer time.

MP3 Player is an irie tool!

Reply to this topic