jQuery Load Content

The jQuery Load Content plugin was developed to make more easy to load content of json and html of requisitions in a web page.

Download on Github

Demo

Div Tag - is in the default elements, should be loaded.

P Tag - is in the default elements, should be loaded.

Span Tag - is NOT in the default elements, should not be loaded.

Html

<div data-ajax="example.json">Div Tag - is in the default elements should be loaded.</div>
<p data-ajax="example.json">P Tag - is in the default elements should be loaded.</p>
<span data-ajax="example.json">Span Tag - is NOT in the default elements, should not be loaded.</span>

Example:

<script src="jquery.loadcontent.min.js">
$('body').loadcontent();

Specific element example:

$('#div-load').loadcontent({
    contentType: "html",
    onSucess: function (element, response) {
        element.html(response);
    }
});

Options

Option Default Description
Elements "div, p" These will be the tags selected if they have the attribute "data-ajax".
ContentType "json" The content type that will be loaded.
onSucess callback The callback function used after the ajax requisition. The default function is: function (element, response){ element.html(response.content); }

Author

@willcampideli

Available under the MIT license.

Reference: jQuery Boilerplate.