简体   繁体   English

Web开发:如何从嵌入式C代码到javascript访问变量?

[英]Web Development: how to access a variable from an embedded c code to javascript?

I'm new to web development and I'm using AppWebServer to AppWeb to host my website. 我是Web开发的新手,正在使用AppWebServer到AppWeb托管我的网站。 AppWeb provides ESP (Embedded Server Pages) that is used to create web applications. AppWeb提供用于创建Web应用程序的ESP(嵌入式服务器页面)。 You may embed a C code. 您可以嵌入C代码。

Now my problem is. 现在我的问题是。 I have a javascript code and a C Code, I need to access a variable from the C code and use it in javascript, the question is how do I do that? 我有一个JavaScript代码和一个C代码,我需要从C代码访问一个变量并在javascript中使用它,问题是我该怎么做?

I am thinking that even if I declare the variable as global, I wont still be able to access. 我在想,即使我将变量声明为全局变量,也仍然无法访问。

您可以使用HTML创建隐藏的输入类型,并用<input type="hidden" id="something" value <%=function in c that returns your variable%>" />插入所需的变量,然后访问它使用您的JavaScript使用getElementById("something")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM