2016-10-02 29 views
1

混合內容我得到了我的JS函數來獲取新的職位一個內部下面的代碼,當用戶點擊按鈕Load moreJquery.get()時,試圖獲取數據,而HTTPS

$.get("/blog/page" + nextPage, function (data) {

代碼工作很好,當我在本地測試它。

當我把它推到gh頁時,它看起來很好。但是,當我點擊Load more按鈕,我得到以下錯誤:

Mixed Content: The page at 'https://username.github.io/sub-name/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://username.github.io/sub-name/blog/page2/'. This request has been blocked; the content must be served over HTTPS.

我已經添加到baseurl文件_config.yml但它並沒有解決問題。

+0

你可以添加回購嗎?我有一個想法(壞的參考),但需要代碼來確認 – StephenG

回答

0

https://railsr.github.io,您使用_includes/head.html訪問您cssjs文件從您的config文件設置爲http。使用協議獨立//而不是

+0

這是一個私人回購。無法分享。我注意到gh-pages強制使用https exaclty來做這個回購。但是對於例如http://railsr.github.io/autm-rb/使用http。我嘗試將它切換到公共,但它不能解決問題 – kirqe

0

我決定使用不同的方法,現在只需在生成帖子列表的項目根目錄中有posts.json文件。

--- 
--- 

[ 
    {% for post in site.posts %} 
     { 
     "title": "{{ post.title }}", 
     "summary": "{{ post.summary }}", 
     ... 
     } 
     {% unless forloop.last %},{% endunless %} 
    {% endfor %} 
] 

然後在我的js的一個文件使用

$.getJSON("{{site.baseurl}}/posts.json", function(data) {

,然後將數據推送到張貼陣列和顯示訊息分批(加載第一4個訊息,然後加載另一個每秒4「負載更多'按鈕點擊)

(沒有分頁)

相關問題