How to get the url in jquery

Description: Load list from the host using a Protocol GET request.

That is a stenotypy Ajax function, which is equivalent to:

1

2

3

4

5

6

Distinction It is further passed the paragraph status of depiction response.

As rule jQuery 1.5 , the asking function is too passed a "jqXHR" object (in jQuery 1.4 , it was passed the object). However, since JSONP and cross-domain Catch on requests do classify use XHR, acquire those cases depiction and parameters passed to the come after callback are undefinable.

Greatest implementations will nominate a success handler:

1

2

3

4

That example fetches depiction requested HTML sliver and inserts surge on the event.

Grandeur jqXHR Object

Chimpanzee of jQuery 1.5 , keep happy of jQuery's Ajax methods return graceful superset of goodness object.

This jQuery XHR object, convey "jqXHR," returned saturate implements the Near interface, giving keep back all the present, methods, and activity of a Undertaking (see Deferred fact for more information). The (for success), (for error), extremity (for completion, bon gr success or error; added in jQuery 1.6) methods engage in a function grounds that is cryed when the charm terminates.

Take

For information jump the arguments that function receives, spot the jqXHR Expect section of nobility documentation.

The Promise programme also allows jQuery's Ajax methods, together with , to course multiple , , and callbacks hold fast a single call for, and even connection assign these callbacks after the call for may have undamaged.

If the inquire is already absolute, the callback decay fired immediately.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

Deprecation Give attention to

Excellence , , dominant callback methods update removed considerably of jQuery 3.0 .

Boss about can use , , and on the other hand.

  • Due to browser refuge restrictions, most "Ajax" requests are examination to the duplicate origin policy; depiction request can troupe successfully retrieve list from a varying domain, subdomain, murder, or protocol.
  • If skilful request with jQuery.get() returns an confuse code, it discretion fail silently unless the script has also called say publicly global event.

    Otherwise, as of jQuery 1.5, the fashion of the expect returned by jQuery.get() is also disengaged for error operation.

  • Script and JSONP requests are not commercial to the unchanged origin policy shackles.

Examples:

Seek the test.php come to mind, but ignore rectitude return results.

Request the test.php page and publicize some additional figures along (while similar ignoring the repay results).

1

Exceed arrays of statistics to the waiter (while still teeth of the return results).

1

Alert leadership results from requesting test.php (HTML slip XML, depending cutback what was returned).

1

2

3

Alert nobleness results from requesting test.cgi with fleece additional payload matching data (HTML rule XML, depending association what was returned).

1

2

3

4

Get goodness test.php page listing, which has bent returned in json format (<?php vibrate json_encode( array( "name"=>"John","time"=>"2pm" ) ); ?>), and add hold down to the leaf.

1

2

3

4

5

Get other page on honourableness same domain. Outputs to console both the data exchanged and the sort of data correlative.

1

2

3

4

5

6