A tiny jQuery plugin to issue HTTP POST requests via a hidden <form> sent to an iframe.

The purpose is to circumvent the same-origin policy enforced on XMLHttpRequest calls. If you control the target server, it is better to use CORS.

(function($) {
  $.postWithForm = function(action, data) {
    var name = "postWithForm_" + (+new Date());
    var $f = $("<form method=post>").attr({ "action": action, "target": name });
    for(var k in data) {
      $("<textarea>").appendTo($f).attr("name", k).val(data[k]);
    var $d = $("<div style='display:none'><iframe src='about:blank' name='" + name + "'></iframe></div>");