Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added get example
Added a `.get` example to show how to request a different page from the same domain.

Noticed all the examples on this page were for appending to the current url rather than changing the url to another page on the same domain. May be helpful for some people.
  • Loading branch information
rani-k committed Oct 27, 2019
commit 3d084324a211c06354b173c607e7aab50a6477ac
13 changes: 12 additions & 1 deletion entries/jQuery.get.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,24 @@ $.get( "test.cgi", { name: "John", time: "2pm" } )
]]></code>
</example>
<example>
<desc> Get the test.php page contents, which has been returned in json format (&lt;?php echo json_encode( array( "name"=&gt;"John","time"=&gt;"2pm" ) ); ?&gt;), and add it to the page.</desc>
<desc>Get the test.php page contents, which has been returned in json format (&lt;?php echo json_encode( array( "name"=&gt;"John","time"=&gt;"2pm" ) ); ?&gt;), and add it to the page.</desc>
<code><![CDATA[
$.get( "test.php", function( data ) {
$( "body" )
.append( "Name: " + data.name ) // John
.append( "Time: " + data.time ); // 2pm
}, "json" );
]]></code>
</example>
<example>
<desc>Get another page on the same domain. Outputs to console both the data returned and the type of data returned.</desc>
<code><![CDATA[
// If this was sent on https://api.jquery.com/jQuery.get/ you will
// get the response result of https://api.jquery.com/jQuery.ajax/
$.get( "/jQuery.ajax/", function( data ) {
console.log( typeof( data ) );
Comment thread
mgol marked this conversation as resolved.
Outdated
console.log( data );
});
]]></code>
</example>
<category slug="ajax/shorthand-methods"/>
Expand Down