neshkeev
neshkeev

Reputation: 6476

jQuery: Load external html file via https

I am trying to load an external file that contains some html code into a div using jQuery.load, but I failed: Div:

<div id="htmhtm"></div>

jQuery:

$('#htmhtm').load(
'https://github.com/kastolom/diefororacle/blob/master/2014-08-28-pivot/html/article.html'
);

JSFiddle

Could anyone please tell me where the problem is?

I want to have my blog entries outside of the blog hosting, in order to be able to migrate from one resource to another, for example, from blogger.com to wordpress

Upvotes: 0

Views: 344

Answers (1)

guest271314
guest271314

Reputation: 1

Try

create file , save as type json, e.g., content.json

callback({"result":"<p>something that I need to add</p>"})

js

(function () {
    callback = function (data) {
        if ($(data.result).is("p")) {
            $("#htmhtm").html(data.result)
        }
    };  
    $.getJSON("https://raw.[url]/content.json?callback=?");
}());

jsfiddle http://jsfiddle.net/guest271314/wdg14r02/

Upvotes: 2

Related Questions