script added dynamically

Discussion in 'JavaScript' started by crfenix, Apr 23, 2009.

  1. #1
    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 23, 2009 IP
  2. crfenix

    crfenix Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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 -->"
     
    crfenix, Apr 23, 2009 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Hi Claudio,

    You can assign innerHTML & trigger/invoke event :)
    Regards
     
    koko5, Apr 23, 2009 IP
  4. crfenix

    crfenix Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry, now sure if I understand what you mean. Could you give me more details? Thanks!
     
    crfenix, Apr 23, 2009 IP