Skip to content

jQuery.get: Add an example using a root-relative path #1152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Changes from all commits
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
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 ); // string
console.log( data ); // HTML content of the jQuery.ajax page
});
]]></code>
</example>
<category slug="ajax/shorthand-methods"/>
Expand Down