Jquery ajax Local Loading Method (implementation code), jqueryajax
There are many ajax loading methods in jquery, unlike the previous JavaScript ajax method. Next we will introduce the jquery ajax Method for local loading, for more information, see.
Example
$.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 parsing:
From the code above, we can see that the returned data is data, but if we use a DIV with id list to enclose the part of the page for ajax requests, in this way, we use $ (data ). filter ("# list" ).html () to get the HTML content in the DIV
Instance
$ (Document ). ready (function () {function loadMessage () {response (this).html ("loading... "); var o = this; var xmlhttp = $. ajax ({url: "Service/IndexLogin. aspx ", dataType:" html ", success: function (result) {response (o).html (result) ;}}) ;} loadMessage. call ($ ("# addinfo") ;}; <form action = "#" method = "post"> <ul id = "addinfo"> loading... </ul> </form>
The method we used above is actually a simpler method. The load () method loads data from the server through AJAX requests and places the returned data in the specified element.
$(document).ready(function(){ $("#addinfo").load("Service/IndexLogin.aspx", $("#addinfo li")); })
1.Load a php file without passing the parameter $ ("# myID"). load ("test. php ");
// Import the result after test. php is run in the element whose id is # myID
2.Load a PHP file that contains a passing Parameter
$ ("# MyID"). load ("test. php", {"name": "Adam "});
// The imported php file contains a passing parameter, similar to: test. php? Name = Adam
3.Load a PHP file that contains multiple passing parameters. Note: parameters are separated by commas (,).
$ ("# MyID"). load ("test. php", {"name": "Adam", "site": "61dh.com "});
// The imported php file contains a passing parameter, similar to: test. php? Name = Adam & site = 61dh.com
4.Load a PHP file, which uses an array as the passing Parameter
$ ("# MyID"). load ("test. php", {'myinfo [] ', ["Adam", "61dh.com"]});
// The imported PHP file contains an array for passing parameters.
The above jquery ajax partial loading method (Implementation Code) is all the content shared by the editor. I hope you can give us a reference and support the help house.