progress

梳理ajax

本秂侑毒 提交于 2019-11-26 20:07:50
   不讨论IE   什么是ajax:ajax是异步到javascript和XML。简单点说,就是使用 XMLHttpRequest 对象与服务器通信。主要使用其两个特性做以下事: 1.在不重载页面到情况下发送请求, 2.接受并使用从服务器发来到数据。 一、怎样发送http请求: 1.先要创建一个XMLHttpRequest实例: var httpRequest=new XMLHttpRequest(); 2.请求发送后,会收到响应,这时要告诉XMLHttp请求对象是由哪一个函数进行处理,在设置了对象的 onreadystatechange 属性后给它命名,即当请求状态改变时调用 httpRequest.onreadystatechange=func; // 或使用匿名函数 httpRequest.onreadystatechange=function(){/* something */}; 3.声明接到响应后要做的事,需要发送一个实际的请求,调用http的open()和send()方法 httpRequest.open('GET', 'test.txt',true); httpRequest.send(); /* *open() 的第一个参数是请求方法,有GET,POST,HEAD和其他服务器支持的方法; *第二个参数是URL ; *第三个参数是可选,设置请求是否是异步

Stop the browser “throbber of doom” while loading comet/server push iframe

让人想犯罪 __ 提交于 2019-11-26 19:47:22
When using Comet, or Ajax Long Pull techniques - an iframe is usually used. And while that iframe is waiting for the long connection to close, the browser is spinning its throbber (the progress/loading indicator). Some websites, for example etherpad.com, managed to make it stop. How do they do it? Evgeny After digging for a day and a night in the guts of the internets, here is what I came up with: server-sent events - Very cool, currently works only in Opera, but may be part of HTML5 and other browsers may support it sometime. Adds a new element tag with content-type of "application/x-dom

How to create a spinning command line cursor?

寵の児 提交于 2019-11-26 18:21:36
Is there a way to print a spinning cursor in a terminal using Python? nos Something like this, assuming your terminal handles \b import sys import time def spinning_cursor(): while True: for cursor in '|/-\\': yield cursor spinner = spinning_cursor() for _ in range(50): sys.stdout.write(next(spinner)) sys.stdout.flush() time.sleep(0.1) sys.stdout.write('\b') Victor Moyseenko Easy to use API (this will run the spinner in a separate thread): import sys import time import threading class Spinner: busy = False delay = 0.1 @staticmethod def spinning_cursor(): while 1: for cursor in '|/-\\': yield

飞机进度条

别说谁变了你拦得住时间么 提交于 2019-11-26 18:13:01
css部分 *{padding:0; margin:0;} .container{ margin: 0 auto; width: 60%; padding:20px; } .progress{ margin-top: 50px; padding: 10px; background: grey; border-radius: 5px; height: 20px; } .progress::after{ content:""; display: block; margin-top: 9px; width: 100%; border-top: dashed 3px white; } .progress .progress-bar { float: left; height: 100%; position: relative; } .progress .progress-bar span{ display: block; width: 40px; height: 30px; background: #333; position: absolute; right: -40px; top: -50px; color: white; text-align:center; line-height: 30px; border-radius: 3px; } .progress .progress

Busy indication with PyQt progress bar

◇◆丶佛笑我妖孽 提交于 2019-11-26 18:09:51
问题 I'm trying to write a script which will display a busy indication while performing the task. And when the task is over, the progress bar will fill to the end showing that 100% task has been completed. I just want the progress bar to show a task is going on.But when I start the task, busy indication stops.It seems to me that the indication and the task can not continue together. Please help me. Here's mycode: from PyQt4 import QtCore, QtGui from time import sleep try: _fromUtf8 = QtCore

Can onprogress functionality be added to jQuery.ajax() by using xhrFields?

孤者浪人 提交于 2019-11-26 17:37:39
问题 As suggested here: https://gist.github.com/HenrikJoreteg/2502497, I'm trying to add onprogress functionality to my jQuery.ajax() file upload. The upload works fine, and the onprogress event is firing, but not as I expected--instead of firing repeatedly at some time interval, it's firing only once, when the upload has completed. Is there a way to specify the frequency of onprogress refreshes? Or, am I trying to do something that can't be done? Here's my code: $.ajax( { async: true, contentType

HttpClient Post with progress and MultipartEntityBuilder

六月ゝ 毕业季﹏ 提交于 2019-11-26 16:46:45
问题 I try to implement an progress while uploading an file with HttpClient 4.3.3 and MultipartEntityBuilder So actually i execute a post request with the following code HttpClientBuilder builder = HttpClientBuilder.create(); HttpClient httpClient = builder.build(); HttpPost httpPost = new HttpPost(uploadUrl); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); entityBuilder.addPart("filea", new FileBody(filea)); entityBuilder.addPart("fileb", new FileBody(fileb)); final

JavaScript loading progress of an image

╄→гoц情女王★ 提交于 2019-11-26 15:18:22
问题 Is there a way in JS to get the progress of a loading image while the image is being loaded? I want to use the new Progress tag of HTML5 to show the progress of loading images. I wish there was something like: var someImage = new Image() someImage.onloadprogress = function(e) { progressBar.value = e.loaded / e.total }; someImage.src = "image.jpg"; 回答1: With this, you add 2 new functions on the Image() object: Image.prototype.load = function(url){ var thisImg = this; var xmlHTTP = new

Task.Run and UI Progress Updates

与世无争的帅哥 提交于 2019-11-26 14:20:07
问题 This code snippet is from Stephen Cleary's blog and gives an example of how to report progress when using Task.Run. I would like to know why there are no cross thread issues with updating the UI, by which I mean why is invoke not required? private async void button2_Click(object sender, EventArgs e) { var progressHandler = new Progress<string>(value => { label2.Text = value; }); var progress = progressHandler as IProgress<string>; await Task.Run(() => { for (int i = 0; i != 100; ++i) { if

HTML5之fileReader异步读取文件及文件切片读取

大城市里の小女人 提交于 2019-11-26 13:04:44
fileReader的方法与事件 fileReade实现图片预加载 fileReade实现文件读取进度条 fileReade的与file.s实现文件切片读取 一、fileReader的方法与事件 1.方法 FileReader.abort():终止读取操作。返回时,readyState属性为DONE。 FileReader.readAsArrayBuffer():将文件读取为ArrayBuffer数据对象。 FileReader.readAsBinaryString():将文件读取为二进制数据。 FileReader.readAsDataURL():将文件读取为DataURL编码(base64)==>URL格式的字符串。 FileReader.readAsText():将文件读取为文本==》字符串表示的文件内容。 2.事件 FileReader.onloadstart:读取开始时触发 FileReader.onprogress:读取中 FileReader.onloadend:读取完成触发,无论成功或失败 FileReader.onload:文件读取成功完成时触发 FileReader.onabort:中断时触发 FileReader.onerror:出错时触发 3.实现图片读取预览 在Web FileReader API接口实现之前,图片预览的通常做法是先将图片上传至服务器