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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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>
            
          
!
            
              // 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