cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <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>
            
          
!
            
              /* GitHub: https://github.com/ccloli/JSON-CSSP */
            
          
!
            
              // 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
Loading ..................

Console