You can do all sorts of loading in progress meters.
and it's just a tiny callback! Here I use a single complete function that
doubles as a partial function.
var surveyComplete = function(xhr, status){
var xml = xhr.responseXML
if (status=='partial'){
result.html('<h1>'+xhr.responseText.length +
'</h1>')
msg.html(status)
}else if (status!="success"){
result.text(xhr.responseText).wrap("<pre></pre>")
msg.html("<h1>" + status.toUpperCase() + "
requesting:<a href='" + url + "'>" + url +"</a></h1>"
+"<h2>" + xhr.status + ":" +
xhr.statusText+ "</h2>")
}else if (!xml){ //safari webkit
result.text(xhr.responseText).wrap("<pre></pre>")
msg.html("<h1> broken xml:<a href='" + url + "'>" +
url +"</a> </h1>")
}else if (xml.hasChildNodes && !xml.hasChildNodes()){ //
opera
result.text(xhr.responseText).wrap("<pre></pre>")
msg.html("<h1> broken xml:<a href='" + url + "'>" +
url +"</a> </h1>")
}else if (xml.firstChild.nodeName == "parsererror"){
//firefox
result.text(xhr.responseText).wrap("<pre></pre>")
msg.html("<h1> broken xml:<a href='" + url + "'>" +
url +"</a> </h1>"+ $.xml(xml))
}else{
result.html('<h1>'+xhr.responseText.length +
'</h1>')
msg.html(status)
}
}
$.ajax({url:url,datatype:'xml',complete:surveyComplete,
partial:surveyComplete})
On 5/7/07, Alexandre Plennevaux <[EMAIL PROTECTED]> wrote:
jake, can you explain how to use this? It sounds very interesting, but
i'm too noob to fill in the blanks !
thank you
Alexadnre
------------------------------
*From:* [email protected] [mailto:[EMAIL PROTECTED] *On
Behalf Of *????
*Sent:* lundi 7 mai 2007 18:24
*To:* [email protected]
*Subject:* [jQuery] Re: retrive how bytes are loaded...possible?
I thought about.. not with jQuery the way it is, but with a small patch,
you can be alerted to partial loads, and do your loading ... %
with this patch (tested in firefox 2) you can use an extra callback,
partial, similar to complete.
Do you think this should go into the core? it's tiny and opens up a lot of
possible features!
--- src/ajax/ajax.js 2007-05-07 09:18:19.000000000 -0700
+++ src/ajax/ajax copy.js 2007-04-12 12:27: 36.000000000 -0700
@@ -708,10 +708,6 @@
if(s.async)
xml = null;
}
- else if (xml && xml.readyState == 3){
- if (s.partial)
- s.partial( xml, 'partial' );
- }
};
On 5/6/07, amircx <[EMAIL PROTECTED]> wrote:
>
>
>
> hey. can i return in jquery how mutch bytes are loaded ? in that way i
> can do
> instad of "Loading....." message i can calculate precents.... is that
> possible somehow to do somthing like:
> "loading...33%" ....
>
> --
> View this message in context:
http://www.nabble.com/retrive-how-bytes-are-loaded...possible--tf3701796s15494.html#a10351812
>
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
--
Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ
Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.467 / Base de données virus: 269.6.5/792 - Date: 6/05/2007
21:01
--
Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ