Side navigation
#10365 closed enhancement (duplicate)
Opened September 28, 2011 02:26PM UTC
Closed May 06, 2012 02:03AM UTC
Last modified May 06, 2012 02:03AM UTC
onprogress ajax
Reported by: | anonymous | Owned by: | jaubourg |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | ajax | Version: | 1.6.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I wanna know if you have some api of progress event on sending XMLHttpRequest. I have used one example of https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest to do the function on the ajax core on jquery.min.
I think its a good sugestion to do that in the next jquery version.
// Do send the request // This may raise an exception which is actually // handled in jQuery.ajax (so no try/catch here) // Progresso de upload var divporcentagem = $j("#porcentagem"); function onProgress(e) { var percentComplete = ( (e.loaded / e.total)*100 ).toFixed(0); divporcentagem.empty(); divporcentagem.append(percentComplete+"%"); } xhr.upload.onprogress = onProgress; xhr.send( ( s.hasContent && s.data ) || null );
I think its not possible to atach lik a complete:function{} or success.
Thanks.
Attachments (0)
Change History (6)
Changed October 02, 2011 01:16PM UTC by comment:1
component: | unfiled → ajax |
---|---|
description: | I wanna know if you have some api of progress event on sending XMLHttpRequest. I have used one example of https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest to do the function on the ajax core on jquery.min. \ I think its a good sugestion to do that in the next jquery version. \ // Do send the request \ // This may raise an exception which is actually \ // handled in jQuery.ajax (so no try/catch here) \ // Progresso de upload \ var divporcentagem = $j("#porcentagem"); \ function onProgress(e) { \ var percentComplete = ( (e.loaded / e.total)*100 ).toFixed(0); \ divporcentagem.empty(); \ divporcentagem.append(percentComplete+"%"); \ } \ xhr.upload.onprogress = onProgress; \ xhr.send( ( s.hasContent && s.data ) || null ); \ \ I think its not possible to atach lik a complete:function{} or success. \ \ Thanks. → I wanna know if you have some api of progress event on sending XMLHttpRequest. I have used one example of https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest to do the function on the ajax core on jquery.min. \ I think its a good sugestion to do that in the next jquery version. \ \ {{{ \ \ // Do send the request \ // This may raise an exception which is actually \ // handled in jQuery.ajax (so no try/catch here) \ // Progresso de upload \ var divporcentagem = $j("#porcentagem"); \ \ function onProgress(e) { \ var percentComplete = ( (e.loaded / e.total)*100 ).toFixed(0); \ divporcentagem.empty(); \ divporcentagem.append(percentComplete+"%"); \ } \ \ xhr.upload.onprogress = onProgress; \ xhr.send( ( s.hasContent && s.data ) || null ); \ \ }}} \ \ I think its not possible to atach lik a complete:function{} or success. \ \ Thanks. |
milestone: | None → 1.next |
owner: | → jaubourg |
priority: | undecided → low |
status: | new → assigned |
Changed October 03, 2011 10:54AM UTC by comment:2
Actually i think is not a try/catch function just a fuction atched to the xhr object
but i undertand that ou guys make an exception for it so i did some api based on jquery
thanks for the answer.
Changed October 03, 2011 10:54AM UTC by comment:3
Replying to [ticket:10365 anonymous]:
I wanna know if you have some api of progress event on sending XMLHttpRequest. I have used one example of https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest to do the function on the ajax core on jquery.min. I think its a good sugestion to do that in the next jquery version.> > // Do send the request > // This may raise an exception which is actually > // handled in jQuery.ajax (so no try/catch here) > // Progresso de upload > var divporcentagem = $j("#porcentagem"); > > function onProgress(e) { > var percentComplete = ( (e.loaded / e.total)*100 ).toFixed(0); > divporcentagem.empty(); > divporcentagem.append(percentComplete+"%"); > } > > xhr.upload.onprogress = onProgress; > xhr.send( ( s.hasContent && s.data ) || null ); > >I think its not possible to atach lik a complete:function{} or success. Thanks.
Actually i think is not a try/catch function just a fuction atched to the xhr object
but i undertand that ou guys make an exception for it so i did some api based on jquery
thanks for the answer.
Changed October 03, 2011 08:17PM UTC by comment:4
Replying to [comment:2 anonymous]:
Actually i think is not a try/catch function just a fuction atched to the xhr object but i undertand that ou guys make an exception for it so i did some api based on jquery thanks for the answer.
(function(jQuery){
jQuery.ajaxmrQUERY = function(options) {
var configuracoes = {
url : null,
type : null,
data : null,
async: true,
acao : null,
ContentType : "text"
}
var opcoes = jQuery.extend(configuracoes,options);
criarAjaxmr(opcoes);
};
var criarAjaxmr = function(opcoes){
var requisicao = new XMLHttpRequest();
requisicao.upload.onprogress = opcoes.progresso;
requisicao.onload = opcoes.successo;
requisicao.onerror = opcoes.errore;
requisicao.onreadystatechange = function()
{
if(requisicao.readyState==4)
{
if(requisicao.status==200)
{
if(opcoes.ContentType=="text")
{
opcoes.respostadarequisicao(requisicao.responseText);
}
if(opcoes.ContentType=="json")
{
opcoes.respostadarequisicao(JSON.parse(requisicao.responseText));
}
}
}
}
requisicao.open(opcoes.type, opcoes.url, opcoes.async);
if(opcoes.acao=="search")
{
requisicao.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
requisicao.send($j.param(opcoes.data));
}
else
{
requisicao.send(opcoes.data);
}
}
})(jQuery);
Changed May 06, 2012 02:03AM UTC by comment:5
resolution: | → duplicate |
---|---|
status: | assigned → closed |