天气频道脚本嵌入

时间:2012-07-11 19:45:00

标签: ajax embed weather

我似乎无法在我的主页上运行此天气频道脚本。我最初从TWC收到了这个脚本:

document.write('<scr'+'ipt src="'+document.location.protocol+'//wow.weather.com/weather/wow/module/'+wx_locID+'?config='+wx_config+'&proto='+document.location.protocol+'&target='+wx_targetDiv+'"></scr'+'ipt>');  

我收到了一篇谷歌论坛帖子的回复,该帖子使用了jQuery的AJAX getScript方法,该方法似乎适用于在线编辑器JSFiddle。

$(function () {
    $.getScript(document.location.protocol + '//wow.weather.com/weather/wow/module/' + wx_locID + '?config=' + wx_config + '&proto=' + document.location.protocol + '&target=' + wx_targetDiv);
});

它仍无法在页面上运行,并导致脚本的其余部分也不显示。

  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
<div id="wx_module_1232">
   <a href="http://www.weather.com/weather/local/98501">Olympia Weather Forecast, WA (98501)</a>
</div>
  </body>

它可能只是一个我缺少的AJAX导入,因为我是网站建设的新手。

1 个答案:

答案 0 :(得分:0)

您似乎缺少变量的值:wx_locIDwx_configwx_targetDiv。您是否忘记复制这些必需的变量?