[Proto-Scripty] Execute JavaScript within HTML Response to Ajax Request

2010-09-24 Thread Greg
Via Google search, I found this answer today here:
http://stackoverflow.com/questions/278122/how-to-force-javascript-to-execute-within-html-response-to-ajax-request

I have it half working. What I mean is, my response text comes back
and updates my div perfectly with the HTML when evalScripts: false,
however the scripts within the HTML are of course not executed. When I
set evalScripts: true, then the ONLY thing that executes is the
scripts and it outputs it directly to the page instead of loading it
into the div.

I think the problem is that the scripts I am trying to execute are
likely document.writes generated by the Maani charts (http://
www.maani.us/xml_charts/index.php) and so instead of loading text into
the div, the executed scripts just write themselves out to the
browser.

Any ideas on how I can fix this? Here's my Prototype code:

function runCalcs() {
var request = new Ajax.Updater
(
result_tab_frame,ajax_runCalcs.asp,
{
method: get,
evalScripts: true,
onSuccess: function () {
document.getElementById(loading).className = clsHide;
}
}
);
}

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: how to update a function with a remote call

2010-09-24 Thread nephish
Hey there,

Wanted to say thanks for all your help here.
The links especially.
I am still very new at all this and it's a lot to get my head around.
That site is excellent.

sk

On Sep 22, 4:53 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

 You're taking the return value of `new Ajax.Request` and using it to
 set the contents of `weather_table_one`. The return value of `new
 Ajax.Request` is (of course) an Ajax.Request object. It's really worth
 reading the documentation.

 If you want to use the contents of the resource that the Ajax.Request
 loads, you need to use the onSuccess callback:

 function replace_weather_table(){
     zoomy = map.getZoom();
     new Ajax.Request('/weather/update_weather_tables?zoom='+zoomy,
         onSuccess: function(response) {
             weather_table_one.setContents(response.responseText);
         }
     });

 };

 Note that by default, Ajax requests are asynchronous, and so the
 update will happen at some point after the `replace_weather_table`
 function returns. You probably want to handle failures as well.

 More 
 here:http://api.prototypejs.org/ajax/ajax/request/http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-re...

 HTH,
 --
 T.J. Crowder
 Independent Software Engineer
 tj / crowder software / com
 www / crowder software / com

 On Sep 22, 7:22 pm, nephish neph...@gmail.com wrote:



  I am working with a javascript function called Elabel, part of the
  Google maps api
  the Elabel has a function called setContents(html)

  i need to be able to call this function and get new html for it. ( the
  html is a table that displays weather data)

  here is what i have so far

  function replace_weather_table(){
          zoomy = map.getZoom();
          weather_table_one.setContents(new Ajax.Request('/weather/
  update_weather_tables?zoom='+zoomy));

  };

  GEvent.addListener(map,moveend, replace_weather_table);

  i would like to have the contents be those of a partial, but when
  executed, the display only shows [object Object]

  would appreciate any help, thanks

  sk

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: how to update a function with a remote call

2010-09-24 Thread T.J. Crowder
Hi,

Sorry, I missed out an opening bracket. Should have been:

function replace_weather_table(){
zoomy = map.getZoom();
new Ajax.Request('/weather/update_weather_tables?zoom='+zoomy, {
// ^--
this was missing
onSuccess: function(response) {
weather_table_one.setContents(response.responseText);
}
});
};

-- T.J.

On Sep 23, 8:29 pm, nephish neph...@gmail.com wrote:
 Thanks for your help,

 i am getting a syntax error in firebug when i place this in my script.

 missing ) after argument list  in this line
 onSuccess: function(response) {

 i have tried lots of different adjustments.

 thanks
 sk

 On Sep 22, 4:53 pm, T.J. Crowder t...@crowdersoftware.com wrote:



  Hi,

  You're taking the return value of `new Ajax.Request` and using it to
  set the contents of `weather_table_one`. The return value of `new
  Ajax.Request` is (of course) an Ajax.Request object. It's really worth
  reading the documentation.

  If you want to use the contents of the resource that the Ajax.Request
  loads, you need to use the onSuccess callback:

  function replace_weather_table(){
      zoomy = map.getZoom();
      new Ajax.Request('/weather/update_weather_tables?zoom='+zoomy,
          onSuccess: function(response) {
              weather_table_one.setContents(response.responseText);
          }
      });

  };

  Note that by default, Ajax requests are asynchronous, and so the
  update will happen at some point after the `replace_weather_table`
  function returns. You probably want to handle failures as well.

  More 
  here:http://api.prototypejs.org/ajax/ajax/request/http://proto-scripty.wik..

  HTH,
  --
  T.J. Crowder
  Independent Software Engineer
  tj / crowder software / com
  www / crowder software / com

  On Sep 22, 7:22 pm, nephish neph...@gmail.com wrote:

   I am working with a javascript function called Elabel, part of the
   Google maps api
   the Elabel has a function called setContents(html)

   i need to be able to call this function and get new html for it. ( the
   html is a table that displays weather data)

   here is what i have so far

   function replace_weather_table(){
           zoomy = map.getZoom();
           weather_table_one.setContents(new Ajax.Request('/weather/
   update_weather_tables?zoom='+zoomy));

   };

   GEvent.addListener(map,moveend, replace_weather_table);

   i would like to have the contents be those of a partial, but when
   executed, the display only shows [object Object]

   would appreciate any help, thanks

   sk

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] AJAX callbacks are not executed atomically?

2010-09-24 Thread JoJo
I have several lines of code that I want to run atomically (no context
switches to other code). Please look at the following barebones
example that illustrates the issue:

//=

function doAjax() {
 console.info('making request');
 new Ajax.Request(
  url, {
   onSuccess: function() {
 console.info('success');
   },
   onFailure: function() {
console.info('failure');
   },
   onComplete: function() {
console.info('complete');
   }
  }
 );
}

doAjax();
doAjax();

//=

If the processor is faster than the network, I expect the output to
be :

making request
making request
success
complete
success
complete

However, under certain conditions, success+complete is sometimes not
atomic. Here's some output that I have seen:

(A) making request
(A) success
(B) making request
(A) complete
(B) success
(B) complete

This is against my expectations and breaks my code logic - the website
fails to function when complete does not IMMEDIATELY follow success.
Can someone shed some light on why this is happening? I thought AJAX
is only asynchronous while waiting for the server and should become
synchronous as it's executing the callback code...

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] AJAX callbacks are not executed atomically?

2010-09-24 Thread Phil Petree
If you want a() to finish before b() and b() to finish before c() then you
will have to daisy chain in the onComplete code.

On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote:

 I have several lines of code that I want to run atomically (no context
 switches to other code). Please look at the following barebones
 example that illustrates the issue:

 //=

 function doAjax() {
  console.info('making request');
  new Ajax.Request(
  url, {
   onSuccess: function() {
 console.info('success');
   },
   onFailure: function() {
console.info('failure');
   },
   onComplete: function() {
console.info('complete');
   }
  }
  );
 }

 doAjax();
 doAjax();

 //=

 If the processor is faster than the network, I expect the output to
 be :

 making request
 making request
 success
 complete
 success
 complete

 However, under certain conditions, success+complete is sometimes not
 atomic. Here's some output that I have seen:

 (A) making request
 (A) success
 (B) making request
 (A) complete
 (B) success
 (B) complete

 This is against my expectations and breaks my code logic - the website
 fails to function when complete does not IMMEDIATELY follow success.
 Can someone shed some light on why this is happening? I thought AJAX
 is only asynchronous while waiting for the server and should become
 synchronous as it's executing the callback code...

 --
 You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To post to this group, send email to
 prototype-scriptacul...@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: AJAX callbacks are not executed atomically?

2010-09-24 Thread JoJo
I don't need A to finish before B. I need A's callbacks to not be cut
off by B's instantiation.

On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote:
 If you want a() to finish before b() and b() to finish before c() then you
 will have to daisy chain in the onComplete code.

 On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote:
  I have several lines of code that I want to run atomically (no context
  switches to other code). Please look at the following barebones
  example that illustrates the issue:

  //=

  function doAjax() {
   console.info('making request');
   new Ajax.Request(
   url, {
    onSuccess: function() {
      console.info('success');
    },
    onFailure: function() {
     console.info('failure');
    },
    onComplete: function() {
     console.info('complete');
    }
   }
   );
  }

  doAjax();
  doAjax();

  //=

  If the processor is faster than the network, I expect the output to
  be :

  making request
  making request
  success
  complete
  success
  complete

  However, under certain conditions, success+complete is sometimes not
  atomic. Here's some output that I have seen:

  (A) making request
  (A) success
  (B) making request
  (A) complete
  (B) success
  (B) complete

  This is against my expectations and breaks my code logic - the website
  fails to function when complete does not IMMEDIATELY follow success.
  Can someone shed some light on why this is happening? I thought AJAX
  is only asynchronous while waiting for the server and should become
  synchronous as it's executing the callback code...

  --
  You received this message because you are subscribed to the Google Groups
  Prototype  script.aculo.us group.
  To post to this group, send email to
  prototype-scriptacul...@googlegroups.com.
  To unsubscribe from this group, send email to
  prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] IE9 Drag-Drop

2010-09-24 Thread tazz_ben
Are other people seeing issues with script.aculo.us' drag and drop in
the latest beta of IE 9?  I know what to do about this is a bit
complicated because it might be their bug.  But we also don't want a
core feature like that not working when it gets released.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] IE9 Drag-Drop

2010-09-24 Thread Marcus Schwarz
Hi,

 
 Are other people seeing issues with script.aculo.us' drag and drop in
 the latest beta of IE 9?  I know what to do about this is a bit
 complicated because it might be their bug.  But we also don't want a
 core feature like that not working when it gets released.

we've  encountered that issue in each of our products using scripty, drag  
drop is broken in IE9. Our Quick Fix: Setting the X-UA-Header for Internet 
Explorer so it uses IE8-mode to render the pages.

Regards
Marcus

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: AJAX callbacks are not executed atomically?

2010-09-24 Thread JoJo
I believe I solved the problem.  I had a queue of work orders. One of
these work orders queued up another work order, so it was a nested
AJAX request - BAD IDEA!

On Sep 24, 12:56 pm, JoJo tokyot...@gmail.com wrote:
 I don't need A to finish before B. I need A's callbacks to not be cut
 off by B's instantiation.

 On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote:

  If you want a() to finish before b() and b() to finish before c() then you
  will have to daisy chain in the onComplete code.

  On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote:
   I have several lines of code that I want to run atomically (no context
   switches to other code). Please look at the following barebones
   example that illustrates the issue:

   //=

   function doAjax() {
    console.info('making request');
    new Ajax.Request(
    url, {
     onSuccess: function() {
       console.info('success');
     },
     onFailure: function() {
      console.info('failure');
     },
     onComplete: function() {
      console.info('complete');
     }
    }
    );
   }

   doAjax();
   doAjax();

   //=

   If the processor is faster than the network, I expect the output to
   be :

   making request
   making request
   success
   complete
   success
   complete

   However, under certain conditions, success+complete is sometimes not
   atomic. Here's some output that I have seen:

   (A) making request
   (A) success
   (B) making request
   (A) complete
   (B) success
   (B) complete

   This is against my expectations and breaks my code logic - the website
   fails to function when complete does not IMMEDIATELY follow success.
   Can someone shed some light on why this is happening? I thought AJAX
   is only asynchronous while waiting for the server and should become
   synchronous as it's executing the callback code...

   --
   You received this message because you are subscribed to the Google Groups
   Prototype  script.aculo.us group.
   To post to this group, send email to
   prototype-scriptacul...@googlegroups.com.
   To unsubscribe from this group, send email to
   prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
   .
   For more options, visit this group at
  http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: AJAX callbacks are not executed atomically?

2010-09-24 Thread Phil Petree
Same difference.

Since the AJAX calls are Async you have no control over what gets completed
first or what gets interrupted by what.

If script a does a complex query taking 2.2 seconds and returns a large data
set while script b does a simple query that takes .02 seconds and returns
100 bytes, script b will almost certainly interrupt script a.

You have two options (as far as I know), you can daisy chain the calls and
thereby guarantee the call/completion order or you can create your own
semaphore process and lock (sleep) the onComplete of script b until script a
clears the i'm done flag.

On Fri, Sep 24, 2010 at 3:56 PM, JoJo tokyot...@gmail.com wrote:

 I don't need A to finish before B. I need A's callbacks to not be cut
 off by B's instantiation.

 On Sep 24, 12:44 pm, Phil Petree phil.pet...@gmail.com wrote:
  If you want a() to finish before b() and b() to finish before c() then
 you
  will have to daisy chain in the onComplete code.
 
   On Fri, Sep 24, 2010 at 3:21 PM, JoJo tokyot...@gmail.com wrote:
   I have several lines of code that I want to run atomically (no context
   switches to other code). Please look at the following barebones
   example that illustrates the issue:
 
   //=
 
   function doAjax() {
console.info('making request');
new Ajax.Request(
url, {
 onSuccess: function() {
   console.info('success');
 },
 onFailure: function() {
  console.info('failure');
 },
 onComplete: function() {
  console.info('complete');
 }
}
);
   }
 
   doAjax();
   doAjax();
 
   //=
 
   If the processor is faster than the network, I expect the output to
   be :
 
   making request
   making request
   success
   complete
   success
   complete
 
   However, under certain conditions, success+complete is sometimes not
   atomic. Here's some output that I have seen:
 
   (A) making request
   (A) success
   (B) making request
   (A) complete
   (B) success
   (B) complete
 
   This is against my expectations and breaks my code logic - the website
   fails to function when complete does not IMMEDIATELY follow success.
   Can someone shed some light on why this is happening? I thought AJAX
   is only asynchronous while waiting for the server and should become
   synchronous as it's executing the callback code...
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Prototype  script.aculo.us group.
   To post to this group, send email to
   prototype-scriptacul...@googlegroups.com.
   To unsubscribe from this group, send email to
   prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 prototype-scriptaculous%2bunsubscr...@googlegroups.comprototype-scriptaculous%252bunsubscr...@googlegroups.com
 
   .
   For more options, visit this group at
  http://groups.google.com/group/prototype-scriptaculous?hl=en.

 --
  You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To post to this group, send email to
 prototype-scriptacul...@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: marquee in JavaScript (using Prototype)

2010-09-24 Thread Eric Anderson
On Aug 27, 5:43 am, Johan Arensman johanm...@gmail.com wrote:
 I'm fully against marquee's in the first place but you also have an option
 to add the attribute data-duration to your element. If you're making a class
 to replace a depricated functionality you shouldn't use this way to add
 features or configuration to it.

I'm not sure I understand? Isn't data- the new HTML5 way to do custom
element configuration?

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.