亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

嘗試將 html 元素設置為 google trend embed 時出現 PHP 錯誤

嘗試將 html 元素設置為 google trend embed 時出現 PHP 錯誤

PHP
忽然笑 2023-09-15 17:34:02
當嘗試使用 jquery 將元素的 html 屬性設置為 google trend embed 時,我收到錯誤。<!DOCTYPE html><html><head>    <title>Titlw</title></head><body>    <div class="hide" id="google_trends"></div></body><script type="text/javascript">    /*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */</script></html><?phpecho "<script>    $('#google_trends').removeClass('hide');    $('#google_trends').html('<script type=\"text/javascript\" src=\"https://ssl.gstatic.com/trends_nrtr/2213_RC01/embed_loader.js\"></script> <script type=\"text/javascript\"> trends.embed.renderExploreWidget(\"TIMESERIES\", {\"comparisonItem\":[{\"keyword\":\"a\",\"geo\":\"\",\"time\":\"today 5-y\"}],\"category\":0,\"property\":\"froogle\"}, {\"exploreQuery\":\"date=today%205-y&gprop=froogle&q='a'\",\"guestPath\":\"https://trends.google.com:443/trends/embed/\"});</script>');</script>";?>錯誤消息-“未捕獲的語法錯誤:無效或意外的標記”
查看完整描述

1 回答

?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

  1. 您不需要使用echo函數打印輸出。它會將自身嵌入到指定的 div 中。這里的div id是google_trends

  2. 您顯示/隱藏google_trends div 的要求將通過使用Ready函數初始化 jquery 來滿足。頁面加載后,它將刪除 隱藏類并顯示谷歌趨勢請求結果。

  3. 使用renderExploreWidgetTo函數而不是renderExploreWidget。通過這個,您可以定義要在其中顯示輸出的 div id。

嘗試以下代碼。

<!DOCTYPE html>

<html>

<head>

    <title>Titlw</title>

    

</head>

<body>

    <div class="hide" id="google_trends"></div>



    <script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>

    <script type="text/javascript" src="https://ssl.gstatic.com/trends_nrtr/1328_RC04/embed_loader.js"> </script>

 </body>

</html>


<script type="text/javascript">

$( document ).ready(function() {

    $('#google_trends').removeClass('hide');

    trends.embed.renderExploreWidgetTo(google_trends,'TIMESERIES', {'comparisonItem':[{'keyword':'a','geo':'','time':'today 5-y'}],'category':0,'property':'froogle'}, {'exploreQuery':'date=today%205-y&gprop=froogle&q=a','guestPath':'https://trends.google.com:443/trends/embed/'});


});


</script>

注意:這是一個獨立的代碼,因為我添加了 jquery CDN 鏈接和 google trend 的 ember_loader js 文件。


查看完整回答
反對 回復 2023-09-15
  • 1 回答
  • 0 關注
  • 130 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號