Sunday 15 April 2012

jquery - Insert a paragraph from an external HTML page to another HTML page with Javascript -



jquery - Insert a paragraph from an external HTML page to another HTML page with Javascript -

i'm new javascript excuse me if want doesn't create sense. want import paragraph , header external html page html page, possible javascript? if yes can point me can find right info.

page imports going done.

<ul> <li> <h3>header imported form page 1</h3> <p>paragraph imported page 1</p> </li> <li> <h3>header imported form page 2</h3> <p>paragraph imported page 2</p> </li> </ul>

external page 1

<h3>header in page 1</h3> <p>paragraph in page 1</p>

external page 2

<h3>header in page 2</h3> <p>paragraph in page 2</p>

i searched of posts found import finish html pages.

fyi - cannot utilize php since don't have access server.

thanks

you utilize jquery load() method.

the .load() method, unlike $.get(), allows specify portion of remote document inserted. achieved special syntax url parameter. if 1 or more space characters included in string, portion of string next first space assumed jquery selector determines content loaded.

for example:

$( "#result" ).load( "ajax/test.html #container" );

when method executes, retrieves content of ajax/test.html, jquery parses returned document find element id of container. element, along contents, inserted element id of result, , rest of retrieved document discarded.

javascript jquery html ajax json

No comments:

Post a Comment