将 jquery 移植到 java

发布于 2024-12-05 08:38:13 字数 1542 浏览 0 评论 0原文

我有一个jquery cod,我想将它移植到java。由于我不熟悉 java,是否有任何选项可以快速完成此任务

这是我的代码

ASDR.PostStore = function(ec, options) {
        this.ec = ec;
        this.target = options && options.target;
        var self = this;

        var _send = function(url, transaction, pre, post) {
            $(transaction).trigger(pre);
            $(self).trigger(pre, transaction);
            $(self).trigger('sending', transaction);
            $.ajax({
                type    : "POST",
                url     : url,
                data    : transaction.toString(),
                dataType: "json",
                success : function(data) {
                    ec.expand(data, true);//Always updateOnIntern
                    $(self).trigger('sent', data);
                    $(self).trigger(post, data);
                    $(transaction).trigger(post, data);
                },
                error : function(data){
                    console.log("Logging error", data);
                }
            });
        };

        this.get = function(transaction) {
            var url = (this.target + "get");
            _send(url, transaction, 'getting', 'gotten');
        }

        this.persist = function(transaction) {
            var url = (this.target + "persist");
            _send(url, transaction, 'persisting', 'persisted');
        }

        /**
         * Always asynchronous.
         */
        this.is_async = function(){
            return true;
        }
    }
}

提前致谢

Renjith Raj

i have a jquery cod with me and i want to port it to java. Is there any options available to do this task quickly since i am not familiar with java

Here is my code

ASDR.PostStore = function(ec, options) {
        this.ec = ec;
        this.target = options && options.target;
        var self = this;

        var _send = function(url, transaction, pre, post) {
            $(transaction).trigger(pre);
            $(self).trigger(pre, transaction);
            $(self).trigger('sending', transaction);
            $.ajax({
                type    : "POST",
                url     : url,
                data    : transaction.toString(),
                dataType: "json",
                success : function(data) {
                    ec.expand(data, true);//Always updateOnIntern
                    $(self).trigger('sent', data);
                    $(self).trigger(post, data);
                    $(transaction).trigger(post, data);
                },
                error : function(data){
                    console.log("Logging error", data);
                }
            });
        };

        this.get = function(transaction) {
            var url = (this.target + "get");
            _send(url, transaction, 'getting', 'gotten');
        }

        this.persist = function(transaction) {
            var url = (this.target + "persist");
            _send(url, transaction, 'persisting', 'persisted');
        }

        /**
         * Always asynchronous.
         */
        this.is_async = function(){
            return true;
        }
    }
}

Thanks in advance

Renjith Raj

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假装爱人 2024-12-12 08:38:13

jQuery 是Javascript,通常在客户端执行。 Java 是一种在服务器端执行的程序语言。您不能直接将 jQuery 转换为 Java。

不过,您可以使用 GWT 等库,它将 Java 转换为 Javascript。还可以在服务器端静态呈现内容。如果您搜索JSP/JSTL,您会发现很多资源。

jQuery is Javascript, which is usually executed on the client side. Java is a program language which is executed on the server side. You cannot directly convert jQuery to Java.

You can however use a library such as GWT which translates Java to Javascript. There is also the possibility to statically render content server side. If you search for JSP/JSTL you'll find many resources.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文