0

Im trying to load html pages that exists locally on the server in a folder called HTML-FIles.

I want to use jquery to load one file and present its content in a div.

As it is now, I can load the file, but in the div a link is created that leads to the files content. I dont want it as a link, I want the content immediatly.

Here is the script:

function loadAllPosts() {
    $(document).ready(function () {
        var dir = "../HTML-Files";
        var date = "2014-10-16";

        $.get(dir, function (data) {
            $(data).find("a:contains(" + date + ")").each(
                function () {
                    var post = this;
                    $("#content").append($(post));
                });
        });
    });
}
1
  • You need to use the file name as well.. Commented Oct 23, 2014 at 11:43

2 Answers 2

1

You may use .load()

To load data in a div, use the following:

       $(document).ready(function(){
   $("#content").load("YOUR FILE NAME");  //put your file name there in the bracket
});
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to load data on click try this.

$(document).ready(function () {
    $("div").live('click', function () {
        var data_id = $(this).data("id");
        $('#container').load("external.html?" + data_id,myCallback);
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.