I guess it's not possible to use web sockets, can AJAX polling be used with AMP?

ⅰ亾dé卋堺 提交于 2019-12-12 02:59:16

问题


I am looking at using AMP for a page which has a section that gets updated via websockets currently. I assume this isn't possible with AMP, so as a fallback can we use AJAX polling, or can it only be static content?


回答1:


You can't use web sockets or AJAX polling in AMP. However your use case might be better handled with the upcoming amp-live-list component: https://github.com/ampproject/amphtml/issues/2762




回答2:


Only static content. You could add a button to re-direct to a non-AMP JS-based page to do the polling. If you have consistent menus, then the polling page could be equivalent to a pop-up with a return to the AMP page.




回答3:


yes, we can't use ajax in amp page pages but we can try same implementation using amp-list tag

    <amp-list src="http://localhost:3000/comments" 
        [src]="productsState.items" 
        width="320"
        height="144"
        [height]="productsState.items.length * 24"
        class="m1">
<template type="amp-mustache">
  <strong>Product</strong>: {{name}}
  <strong>Price</strong>: ${{price}}
</template>



来源:https://stackoverflow.com/questions/36450831/i-guess-its-not-possible-to-use-web-sockets-can-ajax-polling-be-used-with-amp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!