简体   繁体   English

从服务器运行 javascript

[英]running javascript from a server

I need to be able to run javascript from a server path.我需要能够从服务器路径运行 javascript。 JS files are loaded under /wp-content/uploads/js directory. JS 文件加载在 /wp-content/uploads/js 目录下。

Below button calls Upload() function:下面的按钮调用 Upload() function:

<input style="padding: 10px; font-size: 10px; color: white; border-radius: 0px; text-align: Center; background: #2b86b3; width: 96%;" type="submit" value="Load Summary" onclick="Upload()" />

and this is what I have defined in HTML page:这就是我在 HTML 页面中定义的内容:

<script type="text/javascript" src="/upload/js/uploadsum.js"></script>

But no matter what it the uploadsum.js doesn't run.但无论如何,uploadsum.js 都不会运行。 Since uploadsum.js contains upload() function do I need to define upload() function outside uploadsum?js script?由于uploadsum.js 包含upload() function 我是否需要在uploadsum?js 脚本之外定义upload() function?

Thanks.谢谢。

It has worked.它奏效了。 I was with ipage support.我有 ipage 支持。 They did something in backend to make it work.他们在后端做了一些事情来使它工作。 Initially ipage said javascripts are not supported but when I requested them to look into this it worked.最初 ipage 说不支持 javascript,但是当我要求他们调查时,它起作用了。

You told the js files are on the path ( uploads with 's'):您告诉 js 文件在路径上(使用 's'上传):

/wp-content/uploads/js 

But for src attribute you passed following location ( upload without 's'):但是对于 src 属性,您传递了以下位置(上传不带 's'):

/upload/js/uploadsum.js

That's the issue possibly可能是这个问题

Edit: See this编辑:看到这个

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

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