我对这个ajax计时器有问题,它没有做我期望的事情,也没有执行

b1payxdu  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(223)

好了,我回到这个不执行的地方了,我在php中有如下内容https://deniserose.000webhostapp.com/fetch_sql.php

  1. <head>
  2. <title>Audio Stream</title>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  6. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js">
  7. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  8. </head>

我在php文件末尾加载了java脚本

  1. <script src = 'js/fetch_updater.js'></script>

现在这似乎永远也跑不动了

  1. // Start Clock refresh
  2. // uses new new Ajax.PeriodicalUpdater(
  3. // in main fetch file to trigger the auto update of the page.
  4. // Written by Denise Rose
  5. var gUpdateDiv="";
  6. var gContentURL="";
  7. var gcheckInterval=0;
  8. var gcheckURL = "";
  9. var gCurrentCheck ="";
  10. _fetchUpdater('track_data','/fetch_sql.php','/fetch_sql.php',6000);
  11. function _fetchUpdater(updateDiv,contentURL,checkURL,checkInterval)
  12. {
  13. gUpdateDiv = updateDiv;
  14. gContentURL = contentURL;
  15. gcheckInterval = checkInterval;
  16. gCheckURL = checkURL;
  17. setTimeout('Check();',gcheckInterval);
  18. }
  19. //Called by _fetchUpdater every (n) seconds determines if content should be updated as page loaded.
  20. function Check()
  21. {
  22. new Ajax.Request(gCheckURL,{method:'get', onSuccess:CheckResponse});
  23. setTimeout('Check();',gcheckInterval);
  24. }
  25. // looks for the response and determines if the div should be updated.
  26. var openFile = function(event) {
  27. var input = event.target;
  28. var reader = new FileReader();
  29. reader.onload = function(){
  30. var text = reader.result;
  31. var node = document.getElementById('output');
  32. node.innerText = text;
  33. console.log(reader.result.substring(0, 200));
  34. };
  35. reader.readAsText(input.files[0]);
  36. };
  37. function CheckResponse(transport)
  38. {
  39. var content = transport.response.Text;
  40. var base64file1 = openFile('/images/nowplaying-artwork_2.png');
  41. var base64file2 = $('outerimg').$('#np_track_artwork').src.value;
  42. if(base64file1 != base64file2) {
  43. //if(gCurrentCheck != content) {
  44. gCurrentCheck = content;
  45. new Ajax.Request(gContentUrl, {method: 'get',onSuccess:function t() {
  46. $(gUpdateDiv).innerHTML = t.responseText; /*t.response.json()*/}
  47. });
  48. $time = new Date().getTime();
  49. new Ajax.Request('outer_img', {method: 'get',onSuccess:function s() {
  50. $('outer_img').innerHTML = "<img id='#np_track_artwork' src='/images/nowplaying_artwork_2.png?t='"+$time+" alt='Playing track artwork' width='200' height='200'>"}
  51. });
  52. }
  53. //setTimeout('Check();',gcheckInterval);
  54. }

它应该在images/nowplaying_artwork_2.png上查看网站上的图像,并使用javascript和ajax调用检查其是否与屏幕上的图像一致。我知道目录中的那个正在更改,但据我所知,它永远不会被激活,除非你刷新整个页面。使用crtl+shift-i。一定是我做错了什么?但我不明白为什么它不执行。你能帮忙吗?这像目录位置一样愚蠢吗?
我在麻省理工学院原型javascript框架1.7.2版中发现了这个错误
(c) 2005-2010山姆·斯蒂芬森
这就是[violation]“settimeout”处理程序占用296299ms prototype.js的时间

  1. function delay(timeout) {
  2. var __method = this, args = slice.call(arguments, 1);
  3. timeout = timeout * 1000;
  4. return window.setTimeout(function() {
  5. return __method.apply(__method, args);
  6. }, timeout);
  7. }

好的,我看了代码检查,它确实运行checkresponse(),它需要非推断,不像settimeout(),有人能帮忙吗,因为它没有进一步的进展,它可能是我的base64东西,但需要帮助吗?有没有可能我读的Java代码不起作用?拥抱谢谢你的关注:d

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题