[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