I have searched religiously here and elsewhere online for resolution to my problem to no avail. I have found many code snippets with samples from javascript to jquery that claim to be able to create and write to a txt or html file, but none of them have worked for me. Here is my issue...

我在这里和其他地方进行了宗教搜索,以解决我的问题无济于事。我发现了许多代码片段,其中包含从javascript到jquery的样本,声称能够创建和写入txt或html文件,但它们都没有为我工作。这是我的问题......

I have a nice little very light php (or html) page that uses a javascript API to record a video, upload it to a server in the cloud and provide me with a token by which I can access that video for playback. It works very nicely to that point.

我有一个很好的非常轻的php(或html)页面,它使用javascript API录制视频,将其上传到云端的服务器,并为我提供一个令牌,通过该令牌我可以访问该视频进行播放。它非常适合这一点。

What I'm trying to do is capture the javascript variable containing the token, then create a new html (or php) file that contains the very simple code using that token to display the video.

我要做的是捕获包含令牌的javascript变量,然后创建一个新的html(或php)文件,其中包含使用该令牌显示视频的非常简单的代码。

Here's the essense of the code...

这是代码的本质......

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//assets.ziggeo.com/css/ziggeo-betajs-player.min.css" />
<script src="//assets.ziggeo.com/js/ziggeo-jquery-json2-betajs-player.min.js">
</script>
<script>
ZiggeoApi.token = "883afacbe59949feae1c9c661d653257";
ZiggeoApi.Events.on("submitted", function (data) {
    var token = '<ziggeo ziggeo-video=' + data.video.token + '>';
    document.getElementById("output").innerHTML=token;
});
</script>
</head>
<body>
<!-- next line displays the recorder -->
<ziggeo></ziggeo>
<p></p>
<font color=black>
<!-- next line displays the recorded video using the generated token for id -->
<p id='output'></p>
</font>
</body>
</html>

...in the above, after a video is created the ZiggeoApi.Events.on("submitted"... line returns the token in data.video.token. I then am trying to do rather than show the video on the same page in an element identified by "id" is output the code in the head section plus this in the body section of a new html file... '' ...but every javascript effort to do that has failed. No errors, no complaints, and no file.

...在上面,在创建视频后,ZiggeoApi.Events.on(“提交”...行返回data.video.token中的标记。然后我尝试做而不是在同一视频上显示视频由“id”标识的元素中的页面输出head部分中的代码加上新html文件的body部分中的代码...''...但是每次javascript工作都失败了。没有错误,没有抱怨,没有档案。

I tried converting the javascript variable data.video.token to a php variable, because I know I can make php write the file. I have working code for that, except the conversion of the javascript var to a php var isn't working either.

我尝试将javascript变量data.video.token转换为php变量,因为我知道我可以让php写入文件。我有工作代码,除了将javascript var转换为php var也无效。

Any help appreciated.

任何帮助赞赏。

Here are some samples of code I've tried to get the file to write...

以下是我试图让文件写入的一些代码示例...

<script>
var txtFile = "test.html";
var file = new File(txtFile);
var str = '<ziggeo ziggeo-video=' + data.video.token + '>';
file.open("w"); // open file with write access
file.write(str);
file.close();
</script>

...above didn't work...

......以上没有用......

<script>
import System.IO;
import System;  // Used for getting the date
function Start () {
    // Create an instance of StreamWriter to write text to a file.
    sw = new StreamWriter("/home4/htlwoadm/public_html/ziggeo/test.txt");
    // Add some text to the file.
    sw.Write("This is the ");
    sw.WriteLine("header for the file.");
    sw.WriteLine("-------------------");
    // Arbitrary objects can also be written to the file.
    sw.Write("The date is: ");
    sw.WriteLine(DateTime.Now);
    sw.Close();
}
</script>

...above didn't work at all... so didn't try to modify it...

......以上根本不起作用......所以没有尝试修改它......

<html><head></head>
<body>
<script>
WriteFile();
</script>
<script>
function WriteFile()
{
        var fh = fopen("test.html", 3); // Open the file for writing
        if(fh!=-1) // If the file has been successfully opened {
                var str = "Some text goes here...";
                fwrite(fh, str); // Write the string to a file
                fclose(fh); // Close the file
        }

}
</script>
</body></html>

...above also didn't work so didn't modify it either...

...上面也没有用,所以没有修改它......

<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "Jane Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
?>

...above works, but can't seem to get the javascript variable up above (data.video.token) to convert to php so haven't modified it either.

...上面的工作,但似乎无法获得上面的javascript变量(data.video.token)转换为PHP所以也没有修改它。

Any help appreciated.

任何帮助赞赏。

1 个解决方案

#1


0

Submitting values from the browser to your server is usually done via some sort of HTTP POST call. You can either do that via AJAX (see e.g. here: jQuery send string as POST parameters) or via a "traditional" html form (see e.g. here: How to add additional fields to form before submit?).

从浏览器向服务器提交值通常是通过某种HTTP POST调用完成的。您可以通过AJAX(请参阅此处:jQuery发送字符串作为POST参数)或通过“传统”html表单执行此操作(请参阅此处:如何在提交之前向表单添加其他字段?)。

更多相关文章

  1. 五十行javascript代码实现简单的双向数据绑定
  2. 在内容可编辑DIV中的选定文本周围包装bb代码
  3. 常用验证JS代码基础及实例
  4. 试着在我的javascript代码中理解“this”(一件事有效,另一件没有)
  5. 代码点火-如何从控制器返回Json响应
  6. 小弟初学网页(javascript),看不懂下面的代码。但又要完成任务 各位
  7. 使用jquery在textarea中的颜色代码
  8. 为什么我的javascript/jquery代码不能像预期的那样工作?
  9. 实现浮动广告的代码

随机推荐

  1. 什么是 Java 对象分配率
  2. 一个正则式引发的血案
  3. Java 正则表达式教程及示例
  4. Tomcat 单机多实例部署
  5. 谷歌android CTS认证
  6. 20 个设计模式和软件设计面试问题
  7. 什么时候使用 CountDownLatch
  8. 数据结构--时间复杂度与空间复杂度
  9. JUnit Theories 介绍
  10. Android中gradle的配置