[Proto-Scripty] Re: Prototype AJAX call IE6 - not working

2011-11-09 Thread Victor
[offtop]
Jessica, do you know about much shorter synonym of 
document.getElementById()?
[/offtop]

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/QhSgSlhmf0sJ.
To post to this group, send email to prototype-scriptaculous@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: Prototype AJAX call IE6 - not working

2011-11-08 Thread T.J. Crowder
Hi,

It would have been really helpful if you'd pointed out which line was
line 37, since things tend to get re-wrapped. :-)

But the problem is here:

     onException: function(response) {
         alert(Failed + response.responseText);
     },
---^

That dangling comma at the end of the object literal you're passing
into Ajax.Request. Most JavaScript engines are fine with it, and it's
now even officially supported (there was some ambiguity before the
ECMAScript 5th ed. spec came out a couple of years ago), but older
versions of IE choke on it. Remove the dangling comma and it should
stop complaining. There's a similar problem with dangling commas at
the ends of array literals (e.g., given `var a = [1, 2, 3, ];`, what's
the length of `a`?).

More:
http://blog.niftysnippets.org/2010/09/literal-improvement.html

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

On Nov 8, 8:36 pm, Jessica Smith jazz...@gmail.com wrote:
 Hi, I'm a total n00b when it comes to AJAX and Prototype.  I do have
 an example that works in IE7+, FF and Chrome, but not IE6.  I'm
 getting the following JS error when I include the function in my test
 page.  I tried including the XMLHttpRequest section thinking that
 might be part of my problem, but it doesn't make a difference.  Any
 suggestions are welcome.

 [error]
 Line: 37
 Char: 5
 Error: Expected identifier, string or number
 Code: 0
 [/error]

 [code]
 html
 head
 titlef1/title
 script type=text/javascript
 if (!window.XMLHttpRequest) {
   window.XMLHttpRequest = function() {
     return new ActiveXObject('Microsoft.XMLHTTP');
   }}

 /script
 script type=text/javascript src=prototype.js/script
 script type=text/javascript
 var cdInterval=0;
 var cdTime=cdInterval+1;
  function changeCart(cartname) {
   alert(cartname);
   document.getElementById(cartname).innerHTML = cartname;
   //setTimeout(ajaxlastcall(),500);
  }

 function ajaxlastcall() {
     url = http://devmachineurl/sid.htm?
 sid=6680prg=menuframe=lastcall;
     new Ajax.Request(url, {
         onSuccess: function(response) {
           var data =
 response.responseXML.getElementsByTagName( 'LastCallData' );
           for( var i = 0; i  data.length; i++ ) {
               var interval = data[i].getAttribute( 'interval' ) - 0;
               var lastcall = data[i].getAttribute( 'lastcall' );
           }
           if (interval == 0)
               document.getElementById(lct).innerHTML=lastcall;
           else startit(interval,lastcall);
         },
         onException: function(response) {
             alert(Failed + response.responseText);
         },
     });

 }

 /script
 /head
 body
 div id=cartnamePlease select a cart./div
 input type=hidden id=toggleval name=toggleval value=yes
 /body
 /html
 [/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-scriptaculous@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: Prototype AJAX call IE6 - not working

2011-11-08 Thread Phil Petree
LOL i was sitting here with phone in hand, counting the lines and had just
zeroed in on the same line when your answer came in.
On Nov 8, 2011 5:38 PM, T.J. Crowder t...@crowdersoftware.com wrote:

 Hi,

 It would have been really helpful if you'd pointed out which line was
 line 37, since things tend to get re-wrapped. :-)

 But the problem is here:

  onException: function(response) {
  alert(Failed + response.responseText);
  },
 ---^

 That dangling comma at the end of the object literal you're passing
 into Ajax.Request. Most JavaScript engines are fine with it, and it's
 now even officially supported (there was some ambiguity before the
 ECMAScript 5th ed. spec came out a couple of years ago), but older
 versions of IE choke on it. Remove the dangling comma and it should
 stop complaining. There's a similar problem with dangling commas at
 the ends of array literals (e.g., given `var a = [1, 2, 3, ];`, what's
 the length of `a`?).

 More:
 http://blog.niftysnippets.org/2010/09/literal-improvement.html

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

 On Nov 8, 8:36 pm, Jessica Smith jazz...@gmail.com wrote:
  Hi, I'm a total n00b when it comes to AJAX and Prototype.  I do have
  an example that works in IE7+, FF and Chrome, but not IE6.  I'm
  getting the following JS error when I include the function in my test
  page.  I tried including the XMLHttpRequest section thinking that
  might be part of my problem, but it doesn't make a difference.  Any
  suggestions are welcome.
 
  [error]
  Line: 37
  Char: 5
  Error: Expected identifier, string or number
  Code: 0
  [/error]
 
  [code]
  html
  head
  titlef1/title
  script type=text/javascript
  if (!window.XMLHttpRequest) {
window.XMLHttpRequest = function() {
  return new ActiveXObject('Microsoft.XMLHTTP');
}}
 
  /script
  script type=text/javascript src=prototype.js/script
  script type=text/javascript
  var cdInterval=0;
  var cdTime=cdInterval+1;
   function changeCart(cartname) {
alert(cartname);
document.getElementById(cartname).innerHTML = cartname;
//setTimeout(ajaxlastcall(),500);
   }
 
  function ajaxlastcall() {
  url = http://devmachineurl/sid.htm?
  sid=6680prg=menuframe=lastcall;
  new Ajax.Request(url, {
  onSuccess: function(response) {
var data =
  response.responseXML.getElementsByTagName( 'LastCallData' );
for( var i = 0; i  data.length; i++ ) {
var interval = data[i].getAttribute( 'interval' ) - 0;
var lastcall = data[i].getAttribute( 'lastcall' );
}
if (interval == 0)
document.getElementById(lct).innerHTML=lastcall;
else startit(interval,lastcall);
  },
  onException: function(response) {
  alert(Failed + response.responseText);
  },
  });
 
  }
 
  /script
  /head
  body
  div id=cartnamePlease select a cart./div
  input type=hidden id=toggleval name=toggleval value=yes
  /body
  /html
  [/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-scriptaculous@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.



-- 
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-scriptaculous@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.