Apache server has a server variable for detecting this... the variable is 'HTTP_X_REQUESTED_WITH' == 'xmlhttprequest'
If you are not running apache or your apache installation does not support this then i would simply add a variable to your Ajax request that says it must be .. in the ele.request... parameters : { isHttpRequest : true } HTH Alex Mcauley http://www.thevacancymarket.com ----- Original Message ----- From: "moesian" <rolandlamb...@googlemail.com> To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com> Sent: Tuesday, October 13, 2009 8:21 AM Subject: [Proto-Scripty] Firefox Ajax problem > > Hi I'm having a problem in Firefox detecting if the request is > xmlHttpRequest in my php code, my code seems to work fine when using > IE and Chrome. I'm using Magento which is based on the Zend Framework > and using the Zend isXmlHttpRequest() function to test whether or not > the request is an xhr one or not. In Firefox this seems to return > false even when I make an ajax call using Prototype. > > Here's the prototype code, perhaps I'm doing something wrong here: > > var shop = { > cart: { > init: function(){ > var product_forms = $$('.ajax-add-to-cart'); > if (!product_forms[0]) return; > product_forms.invoke('observe', 'submit', shop.cart.add); > }, > add: function(e){ > var ele = e.element(); > ele.request({ > onFailure: function() {}, > onSuccess: function(t) {$('header-cart').replace > (t.responseText);} > }); > Event.stop(e); // stop the form from submitting > > }, > remove: function(productId){ > > } > } > } > > And here's the php code that tests if its an xhr request: > > if($this->getRequest()->isXmlHttpRequest()) > { > $this->loadLayout(); > $this->getResponse()->setBody($this->_getSideCartHtml()); > } > else > { > Varien_Profiler::start(__METHOD__ . 'cart_display'); > $this->loadLayout(); > $this->_initLayoutMessages('checkout/session'); > $this->_initLayoutMessages('catalog/session'); > $this->getLayout()->getBlock('head')->setTitle($this->__ > ('Shopping Cart Ajax 2')); > $this->renderLayout(); > Varien_Profiler::stop(__METHOD__ . 'cart_display'); > } > > Thanks in advance for any help, this one has me really scratching my > head. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---