Javascript 通过 http cmd 获取值
我正在尝试从 url 中获取值: http://localhost:8080/bin/task_status?id=2&cmd=完成百分比 我不确定如何在 javascript (ajax) 命令中实际执行此操作,一旦页面加载,将每 0.5 秒调用一次。它使用AJAX内置的进度条来显示。
I am trying to grab a value from a url:
http://localhost:8080/bin/task_status?id=2&cmd=percent_done
I am unsure how to actually do this within a javascript (ajax) command that once the page has been loaded will be called every .5 seconds. It is using the AJAX built in progress bar to display.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 jQuery 中,您可以执行以下操作:
setInterval()
是一个内置 JavaScript 函数,每 X 毫秒重复一次命令,而$.get()
执行 AJAX 请求。正如 @Pointy 在评论中提到的,只有当页面也托管在 localhost:8080 上时,这才有效
In jQuery you can do:
setInterval()
is a built-in JavaScript function that repeats a command every X milliseconds, and$.get()
performs an AJAX request.As @Pointy mentioned in a comment, this will work only if the page is also hosted on localhost:8080
您始终可以使用 javascript 命令:location.href 并手动解析它。
您可以在此处找到演示。
you can always use the javascript command: location.href and parse it manually.
you can find a demonstration over here.