This method will allow you to use a stream very similar to $.post() , since it works transparently with the user and includes a callback function:
<img /> <iframe id="workFrame" style="display: none"></iframe> <form action="php/navTabs.php" target="workFrame" method="post" style="display: none"> <input type=hidden id="hidden-1"> <input type=hidden id="hidden-2"> </form> <script> $('#hidden-1').val('some value to send to the server'); $('#hidden-2').val('some OTHER value to send to the server'); $('img').on('click', function () { $('form').trigger('submit'); }); </script>
It uses a form with hidden inputs (so it may be transparent to the user). You can set the value of the hidden inputs using JavaScript, and then programmatically submit the form to a hidden iframe.
Another feature of this method is that you can bind to the load event for the iframe and have a callback function, as in $.post() :
$('#workFrame').on('load', function () { var response = $(this).contents().filter('body');
UPDATE
If all you want to do is see the result from your PHP script, then you can use your developer tools (FireBug, etc.) to view the response. You can also register the response in an AJAX callback:
$.post("php/navTabs.php", { action: "deleteTab", theHTM: thehtm }, function(jdata) { alert("The tab was " + jdata.is_deleted); console.log(jdata); }, "json");
If you are not currently using Dev. Tools with a console, I highly recommend checking out FireBug , this will save you an amazing amount of debug time code.
source share