Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
<head>
<meta charset="utf-8">
<title>JSON-CSSP Test</title>
</head>

<body>
<input type="text" name="input" id="input">
<button id="btn">Send a Request</button>
<pre id="output" style="max-width: 100%; overflow: auto; white-space: pre-wrap; word-break: break-all;"></pre>
</body>
</html>
              
            
!

CSS

              
                /* GitHub: https://github.com/ccloli/JSON-CSSP */
              
            
!

JS

              
                // json-cssp.js has been included with RawGit: `https://rawgit.com/ccloli/JSON-CSSP/master/json-cssp.js`
(function(){
  var input = document.getElementById('input');
  var btn = document.getElementById('btn');
  var output = document.getElementById('output');

  btn.addEventListener('click', function(){
    var url = '//ccloli.com/test/jsoncssp-example.php?input=' + encodeURIComponent(input.value);

    jsoncssp(url, function(data, params){
      console.log(data);
      var text = '';
      // create an anchor element to get url's parts and check if it is cross-origined
      var urlParser = document.createElement('a');
      urlParser.href = url;

      text += 'Current URL: ' + location.href + '\n';
      text += 'Passed URL: ' + url + '\n';
      text += 'Same Origin: ' + (location.host === urlParser.host) + '\n\n';

			text += 'Request Input: ' + data.request.input + '\n';
			text += 'Request Callback: ' + data.request.jsoncssp + '\n';
      text += 'Response Timestamp: ' + data.timeStamp + '\n';
      text += 'Response Status: ' + data.status + ' - ' + data.message + '\n';

      text += 'Response Data: \n';
      for (var i = 0; i < data.data.length; i++) {
        var curData = data.data[i];
        text += '  - [' + i + ']\n';

        for (var j in curData) {
          text += '    - ' + j + ': ' + curData[j] + '\n';
        }
      }
      text += '\n';

      console.log(params);
      text += 'Response Text: ' + params.res + '\n\n';
      text += 'Final Response Text: ' + params.finalRes + '\n\n';
      text += 'Final JSON: ' + params.data + '\n';

      output.textContent = text;
    });
  });
})();
              
            
!
999px

Console