Frage

I am using JavaScript with ZK framework. In some scenario, I want to post URL from JavaScript in ZK. How to call ZUL file from JavaScript?

Is there any way to post URL using JavaScript in ZK?

War es hilfreich?

Lösung

Assume you have a content.zul and you want to get it via ajax in javascript, this can be done by using zk built in jquery in zul page or using jquery in pure html.

zul sample:

<zk>
    <script><![CDATA[
        function loadContent () {
            jq.ajax({
                url: "content.zul",
                type: "post",
                // callback handler that will be called on success
                success: function(response, textStatus, jqXHR){
                    jq('$content').html(response);
                }
            });
        }
    ]]></script>
    <div id="content"
        onCreate='Clients.evalJavaScript("loadContent();");' />
</zk>

html sample:

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
            window.onload = function () {
                $.ajax({
                    url: "content.zul",
                    type: "post",
                    // callback handler that will be called on success
                    success: function(response, textStatus, jqXHR){
                        $('#content').html(response);
                    }
                });
            }
        </script>
    </head>
    <body>
        <div id="content"></div>
    </body>
</html>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top