This method will allow you to use a flow very similar to $.post()
as it happens transparently to the user and enables 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>
This uses a form with hidden inputs (so this can 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 just like in $.post()
:
$('#workFrame').on('load', function () {
var response = $(this).contents().filter('body');
//if you output JSON in your PHP script you could parse this as JSON and do work
});
UPDATE
If all you want to do is see the output from your PHP script then you can use your Developer Tools (FireBug, etc.) to view the response. You can also log the response in your 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 some Dev. Tools with a console, I highly recommend checking FireBug out, it will save you amazing amounts of time debugging code.