Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
</head>
<body>
    <body>
        ID:<input id="id">
        <button id="test">JSONP 測試</button>
        <span id="result"></span>
    </body>
<script type="text/javascript">
    document.getElementById('test').onclick = function() {
        let id = document.getElementById('id').value;
      
        fetch(`https://openhome.cc/Gossip/ECMAScript/samples/CORS-1.php?id=${id}`, {
            mode : 'cors'
        })
        .then(resp => resp.json())
        .then(person =>  document.getElementById('result').innerHTML = `${person.name}, ${person.age}`);
    };
</script>    
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
JustinSDKpro
0viewers