JSFiddle - React, Tailwind, and code Playground

HTML

<a href="foo.cfm?var1=a&var2=b">Click Me</a>

JavaScript

$(function () {
   $(document).on('click', 'a', function (e) {
     e.preventDefault();
     var newForm = $("<form method='POST'></form>");

     if ($(this).attr('href').indexOf('?') != -1)
     {
       newForm.attr("method", $(this).attr('href').substring(0, $(this).attr('href').indexOf('?')));
       var post_args = $(this).attr('href').substring($(this).attr('href').indexOf('?')+1, $(this).attr('href').length).split('&');

       for (var i in post_args)
       {
         var keyVal = post_args[i].split('=');
           newForm.append($("<input>", { type: "hidden", name:keyVal[0], value:keyVal[1] }));
       }

     }
     else
     {
       newForm.attr("method", $(this).attr('href'));

     }
     console.log(newForm);
     newForm.submit();
   });
});