Cases
The code is as follows |
Copy Code |
$.ajax ({ URL: "Hotelquery!queryhotelbycity.action", Type: "Post", DataType: "HTML", Data: "queryhotel.city=" +cityobj.value+ "&queryhotel.wbcid=" +wbcid, Success:function (data) { $ ("#hotellists"). HTML ($ (data). Filter ("#list"). html (); } }); |
Code resolution:
From the code above, we can see that the data returned is, but if we enclose a div with ID list in the part of the page where the AJAX request is made, we pass $ (data). Filter ("#list"). HTML () You can get the HTML content in the Div.
Instance
The code is as follows |
Copy Code |
$ (document). Ready (function () { function Loadmessage () { $ (this). html ("Loading ..."); var o = this; var xmlhttp = $.ajax ({ URL: "Service/indexlogin.aspx", DataType: "HTML", Success:function (Result) { $ (O). HTML (result); } }); } Loadmessage.call ($ ("#addinfo")); }); <form action= "#" method= "POST" > <ul id= "Addinfo" > In load ... </ul> </form> |
The above is the method we use, in fact, there is a more simple way oh, the load () method to upload data from the server via AJAX request, and put the returned data into the specified element
The code is as follows |
Copy Code |
$ (document). Ready (function () { $ ("#addinfo"). Load ("Service/indexlogin.aspx", $ ("#addinfo Li")); }) |
1. Load a php file, the PHP file does not contain the pass parameter $ ("#myID"). Load ("test.php");
Import test.php Run results in an element with ID #myid
2. Load a PHP file that contains a pass parameter
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {"name": "Adam"}); |
The imported PHP file contains a pass-through parameter, similar to the following: Test.php?name=adam
3. Load a PHP file that contains multiple pass parameters. Note: The parameters are separated by commas
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {"name": "Adam", "Site": "61dh.com"}); |
The imported PHP file contains a pass-through parameter, similar to the following: test.php?name=adam&site=61dh.com
4. Load a php file, the php file with an array as the passing parameters
The code is as follows |
Copy Code |
$ ("#myID"). Load ("test.php", {' myinfo[] ', ["Adam", "61dh.com"]}); |
The imported PHP file contains an array pass parameter.