JSFiddle - React, Tailwind, and code Playground

by supertrue

HTML

<a href="#" onclick="my.html.getHTML('http://jsfiddle.net/supertrue/');">Test AJAX call</a>

JavaScript

var my = my || {};
// ReferenceError: Can't find variable: my ???

jQuery(function ($) {
  my.html = {
    getHTML: function(url) {
      $.ajax({
        url: url,
        dataType: "html",
        success: function( myHTML ) {
          alert(myHTML); // shows string, as expected
          my.html.processHTML(myHTML); //returns null
        }
       });
    },

    processHTML: function ( myHTML ) {
      alert(myHTML);
      // do stuff and return myHTML
    }

  } // end of my.html object
}); // end of jQuery wrapper function