View Full Version : script added dynamically
crfenix
Apr 23rd 2009, 8:39 am
Hi!
Using ajax and jquery I'm calling a function on the server code that returns a javascript script that I need to assign to a div and get executed automatically when assigned.
So far I couldn't do that, seems that the assigned script to the innerHTML of the div can'r be executed dynamically.
Basically I'd like something like assign an alert('hello world') to the innerHTML and automatically see the pop up with the message.
Is this possible?
Thanks!
Claudio
crfenix
Apr 23rd 2009, 1:25 pm
Please, no one has which can be the problem?
var params = '{"stationId":' + stationId + ',"sectionId":' + sectionId + ',"regionId":' + regionId + ',"placement":"728" }';
$jQuery.ajax({
type: "POST",
url: "default.aspx/GetAd",
data: params,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(adId) {
var randomnumber = Math.floor(Math.random() * 1000001);
var params = "id=" + adId +"&ticks=" + randomnumber;
var html = $jQuery.ajax({
url: "/Content/ServeContent.aspx",
data: params,
async: false
}).responseText;
$jQuery("#ctl00_AdPanel1").html(html);
}
});
-----------------------------
this assigment is not working. I'm trying to dinamycally show some google ads but nothing is showed with this code. THANKS!
$jQuery("#ctl00_AdPanel1").html(html);
html = "<!-- begin ZEDO for channel: INT537NYC , publisher: INT537 , Ad Dimension: Super Banner - 728 x 90 -->
<script language="JavaScript">
var zflag_nid="162"; var zflag_cid="1709/1"; var zflag_sid="741"; var zflag_width="728"; var zflag_height="90"; var zflag_sz="14";
</script>
<script language="JavaScript" src="http://c1.zedo.com/jsc/c1/fo.js"></script>
<!-- end ZEDO for channel: INT537NYC , publisher: INT537 , Ad Dimension: Super Banner - 728 x 90 -->"
koko5
Apr 23rd 2009, 1:48 pm
Basically I'd like something like assign an alert('hello world') to the innerHTML and automatically see the pop up with the message.
Is this possible?
Hi Claudio,
You can assign innerHTML & trigger/invoke event :)
Regards
crfenix
Apr 23rd 2009, 2:17 pm
Sorry, now sure if I understand what you mean. Could you give me more details? Thanks!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.