执行 Javascript 服务器端 [英] Execute Javascript server side

查看:73
本文介绍了执行 Javascript 服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对混淆我的 JS 代码很感兴趣,但我意识到周围的论坛没有用.无论如何,我想混淆我的代码.所以我想知道,是否可以在服务器端执行 JS 代码(例如使用 node.js 中的应用程序),然后通过带有上下文的 Ajax 函数(如 dom 或其他东西)调用,在服务器端执行,然后将结果返回给页面.

I was interested in obfuscating my JS code, but I realized arround forums that it is useless. I would like to obfuscate my code anyway. So I was wondering, is that possible to execute JS code on server side (with an app in node.js for example), and just call via Ajax function with context (like dom, or something else), execute on server side, then give back result to page.

这对我来说可能非常有用,它可以只显示基本的 JS 功能,而不是我的应用程序的核心...

It could be very usefull for me, that could permit to just show basic JS functions, but not core of my app...

也许已经存在一个解决方案,但我在网上找不到任何...

Perhaps a solution already exists, but I found nothing on Web...

我认为使用 node.js 已经存在解决方案.我的意思是例如客户端中的一个简单的 JS 函数,例如: call_func('function_name', context);使用ajax调用服务器端JS调度器函数,返回包含结果的JS对象.

I thought that with node.js, a solution was existing. I meant for example a simple JS function in client side like : call_func('function_name', context); that call a server side JS dispatcher function with ajax, that returns JS object containing results.

也许我在做梦?:)

感谢您的帮助.

推荐答案

你可以用 PHP 重写你的计算,或者如果你需要动态使用它们/获得对 DOM 的访问,你可以在服务器端使用 AJAX 进行计算使用 PHP 然后在不重新加载页面的情况下接收 PHP 脚本的输出.

You can either rewrite your calculations in PHP or if you need to use them dynamically/get access to the DOM, you can use AJAX to calculate on the server side using PHP and then recieve the ouput of the PHP script without reloading the page.

您可以在此处阅读有关 AJAX 的信息(我建议使用 jQuery,因为它比尝试理解 HTTP 请求要简单得多):

You can read about AJAX here (I would recommend using jQuery for it as it is much simpler than trying to understand HTTP requests):

http://api.jquery.com/jQuery.ajax/

这篇关于执行 Javascript 服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆