Jquery ajax Local Loading Method (implementation code), jqueryajax

Source: Internet
Author: User

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.

Related Article

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.