jquery get()

    

 

Get

[ edit]

DISAMBIGUATION

It can be:

  • .get() DOM manipulation, or
  • $.get() data transfer method

CONTENTS


[ edit]

$.GET() - DATA TRANSFER METHOD

Load a remote page using an HTTP GET request

[ edit]

Reference

[ edit]

Example

[ edit]
Front-end

jQuery returns the content of the page you are sending the data to using a callback function:

jQuery:

$.get("remote_file_path",
{"param":"param value"},
function(returned_data)
{
alert(returned_data);
});
[ edit]

PHP code example

At the back-end:

<?php
echo 'Welcome '.$_GET['param'];
?>

OUTPUT: Browser will alert, with it's standard pop-up box 'Welcome param value'


[ edit]

.GET() - DOM MANIPULATION

Gets elements specified or creates an array with the matching elements to be used as selectors.

[ edit]

Example

jQuery:

 var _li=$('ul li').get(0); // get first element
alert($(_li).html()); // print element content

HTML:

 <ul>
<li>Hello</li>
<li>Aloha</li>
</ul>

OUTPUT:

 Browser will alert, with its standard pop-up box 'Hello'
主要是这两种方法,操作表单和一个 ajax 请求,get 操作表单,是取一组集合中的某一个,这个集合可以是任何对象。

你可能感兴趣的:(jquery)