[Cartoweb-users] trouble between ajax and sent header

giuseppe.derossi at email.it giuseppe.derossi at email.it
Tue Apr 15 10:44:26 EDT 2008


Hi Oliver,
yes, this is the good way, and I started to study and build it up , anyway,
sorry for the request, is it possible for your team to develope this feature
too,for three reasons ? 
 So it could be used bby other users too. 
 I've developed a number of plug-ins but I don't like the idea to change by
me the internal structure of cartoweb, I did yet it, and updating my system
becomes more and more slow, 
 the last one consists on I'm not good at ajax :)( 
Just for the moment could you give me more info about overrding the function
? 
  
 AjaxHandler.doAction = function(actionId, 
 { ...(see above)... } *should* work.

What is the actionId I've to intercept ? In this way If I performe the
action of downloading a file I should "stop"  ajax only for this action . 
In my pluIn there is a button to download a file, I've to do this on the
event onClick= ?
I'm a bit confused ...

Thanks in advance and best regards

Giu



	--------- Original Message --------
	Da: Oliver Christen <oliver.christen at camptocamp.com>
	To: 
	        Cc: cartoweb-users at lists.maptools.org
	Oggetto: Re: [Cartoweb-users] trouble between ajax and sent header
	Data: 15/04/08 08:38
	
	> 
> 
> 
> Indeed, I havent thought about an action trigered via ajax.
> Sadely the current ajax implementation do not handle mid-course canceling
of 
> the action.
> The thing to do would be to modify a bit the actionRequest function in 
> AjaxHandler.js so the new Ajax.Request call implement an "onLoaded" event 
> which would allow you to interrupt the treatment after the request was
sent. 
> But the documentation of the prototype library 
> (http://www.prototypejs.org/api/ajax/request) state the "onLoaded" event
may 
> not be supported by all browser. A less "clean" way would be to use the 
> "onFailure" event which seems to be supported by all browser.
> 
> something like this:
> 
> cancelActionFlag: false,
> cancelAction: function() {
>   this.cancelActionFlag = true;
> },
> ... (existing code) ...
> doAction: function(actionId, argObject) {
>   ... (existing code) ...
>     var myAjax = new Ajax.Request(url,
>             {method: 'post', postBody: queryObject.post,
>              onComplete: function(response) {
>              ... (existing code) ...
>              }
>              onLoaded: function() {
>                 if (cancelActionFlag) {
>                   Logger.header('--- Action '+ actionId +' canceled ---');
>                   return true;
>                 }
>              }
>              onFailure: function() {
>                 if (cancelActionFlag) {
>                   Logger.header('--- Action '+ actionId +' canceled ---');
>                   return true;
>                 }
>              }
>     });
> },
> 
> and invoque AjaxHandler.cancelAction(); from the buildPostRequest of the 
> ajax code of the plugin that triggered the ajax query
> 
> This is untested but you should get the idea.
> 
> By the way, one should be able to override any core ajax function by
simply 
> redefining the modified function in an new .js file loaded AFTER the main 
> .js file (so puting it at the end of the <head> in the template should do 
> the trick)
> In this case, I presume a AjaxHandler.doAction = function(actionId, 
> argObject) { ...(see above)... } *should* work.
> 
> regards
> Oliver
> 
> 
> > Hi Oliver,
> > I think that sending an output by using the header and then using the
> > instructions
> > readfile();
> > exit;
> > is not a compliant way if there is ajax. It's a case "similar" to my
> > previous (but solved) problem when I sent an echo.
> > In this case there is something pending.
> >
> > The output is sent before the normal output of the plugIn. Even if after

> > the
> > instructions :
> > header()
> > readfile
> > exit
> >
> > there is the normal output of the plugIn, nothing is returned to the 
> > client.
> >
> > Is there a way in order to force the re-sending of the template assign ?

> > or
> > is there something like flush or similar to end the session in a correct

> > way
> > ?
> > This is the first time I use header but by reading on the Internet it is

> > not
> > free from problem.
> > I want to use this system so I can stop any direct access to the
direcory.
> >
> > Please, any advice is welcome.
> >
> > Thanks and best regards
> >
> > Giu
> >
> >
> >
> >
> >
> > --------- Original Message --------
> > Da: Oliver Christen <oliver.christen at camptocamp.com>
> > To: cartoweb-users at lists.maptools.org
<cartoweb-users at lists.maptools.org>
> > Oggetto: Re: [Cartoweb-users] trouble between ajax and sent header
> > Data: 14/04/08 08:33
> >
> > >
> >>
> >>
> >> a frozen map is usualy the result of javascript error, do you have any?
> >>
> >>
> >>
> >> >
> >> > Hi,
> >> > in order to download a file I've used the header way, that is :
> >> >
> >> >            header('Content-Description: File Transfer');
> >> >            header('Content-Type: application/octet-stream');
> >> >            header('Content-Disposition: attachment;
> >> > filename='.basename($file));
> >> >            header('Content-Transfer-Encoding: binary');
> >> >            header('Expires: 0');
> >> >            header('Cache-Control: must-revalidate, post-check=0,
> >> > pre-check=0');
> >> >            header('Pragma: public');
> >> >            header('Content-Length: ' . filesize($file));
> >> >
> >> > the download is ok, but after chosing every button in download
dialog,
> > the
> >> > map is totally freezed , then if I push any button external to the
map,
> >> > for
> >> > example the rows which move the map a bit at south,north east etc,
the
> > map
> >> > has been unfreezed.
> >> >
> >> > A solution could be a reload the page after saving the file, but how 
> >> > can
> > I
> >> > perform this ?
> >> > Is there a way to send the correct header after the first one ?
> >> >
> >> > I've used IE 6.0.
> >> >
> >> > THanks in advace
> >> >
> >> > Please, help it's urgent
> >> >
> >> >
> >> >
> >> > --
> >> > Email.it, the professional e-mail, gratis per te:
http://www.email.it/f
> >> >
> >> > Sponsor:
> >> > Scopri le tue passioni con Leonardo.it!
> >> >
> >> > Clicca qui:
http://adv.email.it/cgi-bin/foclick.cgi?mid=7653&d=20080413
> >> >
> >> >
> >> > _______________________________________________
> >> > Cartoweb-users mailing list
> >> > Cartoweb-users at lists.maptools.org
> >> > http://lists.maptools.org/mailman/listinfo/cartoweb-users
> >> >
> >>
> >>
> >>
> >>
> > --
> > Email.it, the professional e-mail, gratis per te: http://www.email.it/f
> >
> > Sponsor:
> > Una BMW Z4 Roadster a 10?? Prova gratis su Bidplaza.it!
> >
> > Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7673&d=20080414
> >
> >
> > 
> 
> 
> 
>  
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Offerta SKY a 15 € al mese: vedi tutto quello che vuoi tra Mondo, Cinema,
Sport e Calcio.
Solo con SKY puoi avere così tanto per così poco!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7778&d=20080415




More information about the Cartoweb-users mailing list