Show another page when using blockUI plugin

739 Views Asked by At

I would like to get the content of a php file on the click event of an element while blocking the ui by using this plugin. My code is this:

<li onclick="$.blockUI({ message: $.get('page.php') });" />

this does block the UI, but nothing else happens. Does the jQuery get function return the contents of that file? Should I use another function for this purpose?

1

There are 1 best solutions below

6
Jerbot On

What you might be looking to do would be the following:

<li onclick="javascript:showMessage();"></li>

<script type="text/javascript">
function showMessage() {
    $.get('page.php', function(html) {
        $.blockUI({ message: html });
    });
}
</script>

Though if your page.php takes a moment or two to build, blockUI won't fire until it does.

Also, I've had mixed results with putting complex commands in an onclick or href, so I've found it more reliable to call a function.