[Load External files], [load files]

Source: Internet
Author: User

[Load External files], [load files]

 

1. Load External files

<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"> <! -- Prevent garbled characters -->
<Script src = "js/jQuery. js"> </script> <! -- Load the jQuery file -->
<Script src = "js/myjs. js"> </script> <! -- Load jquery js files -->
</Head>
<Body>
<P id = "test"> the original content will be replaced </p>
<Button> Load External files </button>
</Body>
</Html>

// External file myjs
$ (Document). ready (function (){
$ ("Button"). click (function (){
$ ('# Test'). load ('files/new_file.txt') // load External files
})
});

// External file new_file
<H1> my external files

 

In addition:

$ ('# Test'). load ("files/new_file.txt p") // load the p tag in the external file

$ ('# Test'). load ("files/new_file.txt # sel") // load the content of id = sel in the external file

2. Load External files with Parameters

1) $ ('# test'). load ("files/new_file.txt p", function (data, status)

// Data reads the File Content

// Status: the successful call value is success, and the Failure value is error.

2) get request

$. Get ("files/new_file.txt", function (data, status ){
Alert ("data:" + data + "\ n status:" + status );
});

3) post request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.