Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit6070919

Browse files
committed
Update JSONP docs to mention protection against hijacking
1 parente35968d commit6070919

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎content/v3.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ plus the relevant HTTP Header information.
517517
<preclass="terminal">
518518
$ curl https://api.github.com?callback=foo
519519

520-
foo({
520+
/**/foo({
521521
"meta": {
522522
"status": 200,
523523
"X-RateLimit-Limit": "5000",
@@ -533,14 +533,30 @@ foo({
533533
})
534534
</pre>
535535

536-
You can write a JavaScript handler to process the callback like this:
536+
You can write a JavaScript handler to process the callback. Here's a minimal example you can try out:
537537

538-
<pre><codeclass="language-javascript">function foo(response) {
538+
<pre><codeclass="language-html">&lt;html>
539+
&lt;head>
540+
&lt;script type="text/javascript">
541+
function foo(response) {
539542
var meta = response.meta
540543
var data = response.data
541544
console.log(meta)
542545
console.log(data)
543-
}</code></pre>
546+
}
547+
548+
var script = document.createElement('script');
549+
script.src = 'https://api.github.com?callback=foo'
550+
551+
document.getElementsByTagName('head')[0].appendChild(script);
552+
&lt;/script>
553+
&lt;/head>
554+
555+
&lt;body>
556+
&lt;p>Open up your browser's console.&lt;/p>
557+
&lt;/body>
558+
559+
&lt;/html></code></pre>
544560

545561
All of the headers are the same String value as the HTTP Headers with one
546562
notable exception: Link. Link headers are pre-parsed for you and come

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp