logo Posted March 6, 2011 Share Posted March 6, 2011 Hello Did anyone managed to get Ajax buy bow contribution working with SEO URLS 5 ? Thanks Quote Link to comment Share on other sites More sharing options...
Davee Posted March 27, 2011 Share Posted March 27, 2011 Hi Had this working for years but now with firefox 4 it doesn't work Works fine in IE but not firefox The loading gif just shows but doesn't add to cart Any ideas Regards Dave Drako 1 Quote Link to comment Share on other sites More sharing options...
Drako Posted March 31, 2011 Share Posted March 31, 2011 Hi Had this working for years but now with firefox 4 it doesn't work Works fine in IE but not firefox The loading gif just shows but doesn't add to cart Any ideas Regards Dave Same here! Quote my contribution: Alex's Contributions Link to comment Share on other sites More sharing options...
Drako Posted April 15, 2011 Share Posted April 15, 2011 Nobody else got this problem? Quote my contribution: Alex's Contributions Link to comment Share on other sites More sharing options...
meloniq Posted April 19, 2011 Share Posted April 19, 2011 I have got this problem as well (with FF4), already checked on few different pc to exclude posibility that it's fall of some FF plugin and everywhere the same... Have somebody solution fo this? Quote Link to comment Share on other sites More sharing options...
Drako Posted April 19, 2011 Share Posted April 19, 2011 So, i've payed a programmer, and he found the solution. Should be OK to just overwrite the old file, but i suggest a file compare just to be sure. The file is the ajax_sc.JS in the catalog\js folder: SHOW_ADDED = 1; // set 0 if you no need show Offset_X = -10; Offset_Y = -30; /** * Subsys_JsHttpRequest_Js: JavaScript DHTML data loader. * (C) 2005 Dmitry Koterov, http://forum.dklab.ru/users/DmitryKoterov/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * See http://www.gnu.org/copyleft/lesser.html * * Do not remove this comment if you want to use script! * * This library tries to use XMLHttpRequest (if available), and on * failure - use dynamically created <script> elements. Backend code * is the same for both cases. * * @author Dmitry Koterov * @version 3.29 */ function Subsys_JsHttpRequest_Js() { this._construct() } (function() { // to create local-scope variables var COUNT = 0; var PENDING = {}; var CACHE = {}; // Called by server script on data load. Subsys_JsHttpRequest_Js.dataReady = function(id, text, js) { var undef; var th = PENDING[id]; delete PENDING[id]; if (th) { delete th._xmlReq; if (th.caching) CACHE[th.hash] = [text, js]; th._dataReady(text, js); } else if (typeof(th) != typeof(undef)) { alert("ScriptLoader: unknown pending id: "+id); } } Subsys_JsHttpRequest_Js.prototype = { // Standard properties. onreadystatechange: null, readyState: 0, responseText: null, responseXML: null, status: 200, statusText: "OK", // Additional properties. session_name: "osCsid", // set to SID cookie or GET parameter name responseJS: null, // JavaScript response array/hash caching: false, // need to use caching? // Internals. _span: null, _id: null, _xmlReq: null, _openArg: null, _reqHeaders: null, dummy: function() {}, // empty function abort: function() { if (this._xmlReq) return this._xmlReq.abort(); if (this._span) { this.readyState = 0; if (this.onreadystatechange) this.onreadystatechange(); this._cleanupScript(); } }, open: function(method, url, asyncFlag, username, password) { this._openArg = { 'method': method, 'url': url, 'asyncFlag': asyncFlag, 'username': username, 'password': password }; this._id = null; this._xmlReq = null; this._reqHeaders = []; return true; }, send: function(content) { var id = (new Date().getTime()) + "" + COUNT++; // Build QUERY_STRING from query hash. var query = this._hash2query(content); // Append SID to original URL now. var url = this._openArg.url; var sid = this._getSid(); if (sid) url += (url.indexOf('?')>=0? '&' : '?') + this.session_name + "=" + this.escape(sid); // Solve hash BEFORE appending ID. var hash = this.hash = url + '?' + query; if (this.caching && CACHE[hash]) { var c = CACHE[hash]; this._dataReady(c[0], c[1]); return false; } // Try to use XMLHttpRequest. this._xmlReq = this._obtainXmlReq(id, url); // Pass data in URL (GET, HEAD etc.) or in request body (POST)? var hasSetHeader = this._xmlReq && (window.ActiveXObject || this._xmlReq.setRequestHeader); var href, body; if (this._xmlReq && hasSetHeader && (""+this._openArg.method).toUpperCase() == "POST") { // Use POST method. Pass query in request body. // Opera 8.01 does not support setRequestHeader, so no POST method. this._openArg.method = "POST"; href = url; body = query; } else { this._openArg.method = "GET"; href = url + (url.indexOf('?')>=0? '&' : '?') + query; body = null; } // Append ID: a=aaa&b=bbb&<id> href = href + (href.indexOf('?')>=0? '&' : '?') + id; // Save loading script. PENDING[id] = this; if (this._xmlReq) { // Open request now & send it. // In XMLHttpRequest mode request URL MUST be ended with "<id>-xml". var a = this._openArg; this._xmlReq.open(a.method, href+"-xml", a.asyncFlag, a.username, a.password); if (hasSetHeader) { // Pass pending headers. for (var i=0; i<this._reqHeaders.length; i++) this._xmlReq.setRequestHeader(this._reqHeaders[i][0], this._reqHeaders[i][1]); // Set non-default Content-type. We cannot use // "application/x-www-form-urlencoded" here, because // in PHP variable HTTP_RAW_POST_DATA is accessible only when // enctype is not default (e.g., "application/octet-stream" // is a good start). We parse POST data manually in backend // library code. this._xmlReq.setRequestHeader('Content-Type', 'application/octet-stream'); } // Send the request. return this._xmlReq.send(body); } else { // Create <script> element and run it. this._obtainScript(id, href); return true; } }, getAllResponseHeaders: function() { if (this._xmlReq) return this._xmlReq.getAllResponseHeaders(); return ''; }, getResponseHeader: function(label) { if (this._xmlReq) return this._xmlReq.getResponseHeader(label); return ''; }, setRequestHeader: function(label, value) { // Collect headers. this._reqHeaders[this._reqHeaders.length] = [label, value]; }, // // Internal functions. // // Constructor. _construct: function() {}, // Do all work when data is ready. _dataReady: function(text, js) { with (this) { if (text !== null || js !== null) { readyState = 4; responseText = responseXML = text; responseJS = js; } else { readyState = 0; responseText = responseXML = responseJS = null; } if (onreadystatechange) onreadystatechange(); _cleanupScript(); }}, // Create new XMLHttpRequest object. _obtainXmlReq: function(id, url) { // If url.domain specified, cannot use XMLHttpRequest! // XMLHttpRequest (and MS ActiveX'es) cannot work with different domains. if (url.match(new RegExp('^[a-z]+://', 'i'))) return null; // Try to use built-in loaders. var req = null; if (window.XMLHttpRequest) { try { req = new XMLHttpRequest() } catch(e) {} } else if (window.ActiveXObject) { try { req = new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {} if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP") } catch (e) {} } if (req) { var th = this; req.onreadystatechange = function() { var s = req.readyState; if (s == 4) { // Avoid memory leak by removing closure. req.onreadystatechange = th.dummy; // Remove possible junk from response. var responseText = req.responseText; try { // Call associated dataReady(). eval(responseText); } catch (e) { Subsys_JsHttpRequest_Js.dataReady(id, "JavaScript code generated by backend is invalid!\n"+responseText, null); } } else { th.readyState = s; if (th.onreadystatechange) th.onreadystatechange() } }; this._id = id; } return req; }, // Create new script element and start loading. _obtainScript: function(id, href) { with (document) { var span = null; // Oh shit! Damned stupid fucked Opera 7.23 does not allow to create SCRIPT // element over createElement (in HEAD or BODY section or in nested SPAN - // no matter): it is created deadly, and does not respons on href assignment. // So - always create SPAN. span = body.appendChild(createElement("SPAN")); span.style.display = 'none'; span.innerHTML = 'Text for stupid IE.<s'+'cript></' + 'script>'; setTimeout(function() { var s = span.getElementsByTagName("script")[0]; s.language = "JavaScript"; s.type = "text/javascript"; //if (s.setAttribute) s.setAttribute('src', href); else s.src = href; $.get( href, function(data) { s.innerHTML = data; } ); }, 10); this._id = id; this._span = span; }}, // Remove last used script element (clean memory). _cleanupScript: function() { var span = this._span; if (span) { this._span = null; setTimeout(function() { // without setTimeout - crash in IE 5.0! span.parentNode.removeChild(span); }, 50); } return false; }, // Convert hash to QUERY_STRING. _hash2query: function(content, prefix) { if (prefix == null) prefix = ""; var query = []; if (content instanceof Object) { for (var k in content) { var v = content[k]; if (v == null || ((v.constructor||{}).prototype||{})[k]) continue; var curPrefix = prefix? prefix+'['+this.escape(k)+']' : this.escape(k); if (v instanceof Object) query[query.length] = this._hash2query(v, curPrefix); else query[query.length] = curPrefix + "=" + this.escape(v); } } else { query = [content]; } return query.join('&'); }, // Return value of SID based on QUERY_STRING or cookie // (PHP compatible sessions). _getSid: function() { var m = document.location.search.match(new RegExp('[&?]'+this.session_name+'=([^&?]*)')); var sid = null; if (m) { sid = m[1]; } else { var m = document.cookie.match(new RegExp(s='(;|^)\\s*'+this.session_name+'=([^;]*)')); if (m) sid = m[2]; } return sid; }, // Stupid JS escape() does not quote '+'. escape: function(s) { return escape(s).replace(new RegExp('\\+','g'), '%2B'); } } })(); function addHandler(object, event, handler) { // Thanks xpoint.ru! if (typeof object.addEventListener != 'undefined') object.addEventListener(event, handler, false); else if (typeof object.attachEvent != 'undefined') object.attachEvent('on' + event, handler); else { var handlersProp = '_handlerStack_' + event; var eventProp = 'on' + event; if (typeof object[handlersProp] == 'undefined') { object[handlersProp] = []; if (typeof object[eventProp] != 'undefined') object[handlersProp].push(object[eventProp]); object[eventProp] = function(e) { var ret = true; for (var i = 0; ret != false && i < object[handlersProp].length; i++) ret = object[handlersProp][i](e); return ret; } } object[handlersProp].push(handler); } } function removeHandler(object, event, handler) { // Thanks xpoint.ru! if (typeof object.removeEventListener != 'undefined') object.removeEventListener(event, handler, false); else if (typeof object.detachEvent != 'undefined') object.detachEvent('on' + event, handler); else { var handlersProp = '_handlerStack_' + event; if (typeof object[handlersProp] != 'undefined') { for (var i = 0; i < object[handlersProp].length; i++) { if (object[handlersProp][i] == handler) { object[handlersProp].splice(i, 1); return; } } } } } /** AJAXBuyNow v2.0 author Weretennikoff Andrew aka Medreces [email protected] Released under the GNU General Public License */ var x, y; var loadingImage = new Image(); var okImage = new Image(); loadingImage.src = "images/loading.gif"; okImage.src = "images/ok.gif"; if (window.opera || (navigator.userAgent.indexOf('MSIE') > -1)) { //IE + Opera getM_x = function () { return event.clientX + document.body.scrollLeft; } getM_y = function () { return event.clientY + document.body.scrollTop; } } else { // Mozilla addHandler(document, 'mousemove', function(e) { x = e.pageX; y = e.pageY; }); getM_x = function () { return x; } getM_y = function () { return y; } } function showOk() { var imgLoading = document.getElementById("_loading_"); with (imgLoading) { src = okImage.src; style.visibility = "visible"; } } function hideOk() { if(document.getElementById("_loading_")) document.getElementById('_loading_').style.visibility = "hidden"; removeHandler(document, 'mousemove', hideOk); } function showLoading() { var imgLoading = document.getElementById("_loading_"); if(!imgLoading) { imgLoading = document.createElement("img"); with(imgLoading) { id = "_loading_"; style.position = "absolute"; style.visibility = "hidden"; } document.body.appendChild(imgLoading); } with(imgLoading) { src = loadingImage.src; style.left = (getM_x() + Offset_X) + "px"; style.top = (getM_y() + Offset_Y) + "px"; style.visibility = "visible"; } } function hideLoading() { if(document.getElementById("_loading_")) document.getElementById("_loading_").style.visibility = "hidden"; } function doBuyNowGet( link ) { showLoading(); var reqAddCart = new Subsys_JsHttpRequest_Js(); reqAddCart.onreadystatechange = function() { if (reqAddCart.readyState == 4) { if (reqAddCart.responseJS) { document.location.href = reqAddCart.responseJS.ajax_redirect; return; } else { document.getElementById('divShoppingCard').innerHTML = (reqAddCart.responseText||''); hideLoading(); if ( SHOW_ADDED ) { showOk(); timerID = setTimeout( "addHandler(document, \'mousemove\', hideOk)", 500); } } } } //reqAddCart.caching = false; reqAddCart.open('GET', link, true); reqAddCart.send(); } function doAddProduct(form) { showLoading(); var reqAddCart = new Subsys_JsHttpRequest_Js(); reqAddCart.onreadystatechange = function() { if (reqAddCart.readyState == 4) { if (reqAddCart.responseJS) { document.location.href = reqAddCart.responseJS.ajax_redirect; return; } else { document.getElementById('divShoppingCard').innerHTML = (reqAddCart.responseText||'') if ( SHOW_ADDED ) { showOk(); timerID = setTimeout( "addHandler(document, \'mousemove\', hideOk)", 500); } } } } // ñîáèðàåì âñå ýëåìåíòû ôîðìû: var senddata = new Object(); var fe = form.elements; for(var i=0 ; i<fe.length ; i++) { if ( fe[i].type=="radio" || fe[i].type=="checkbox" ) { if ( fe[i].checked ) senddata[fe[i].name] = fe[i].value; } else { senddata[fe[i].name] = fe[i].value; } } var url = 'ajax_shopping_cart.php?' + ( senddata.products_id ? 'products_id='+senddata.products_id+'&' : "" ) + 'action=add_product'; reqAddCart.caching = false; reqAddCart.open( form.method, url, true); reqAddCart.send( senddata ); return false; } Quote my contribution: Alex's Contributions Link to comment Share on other sites More sharing options...
VeganKalle Posted April 26, 2011 Share Posted April 26, 2011 Hi, unfortunately the new ajax_sc.js file doesn't work either. Where the old one didn't put anything in the cart but only displayed the "working"-icon, the new one adds to the cart (you can see the added product after reloading the page) but still only shows the "working"-icon. So it seems that there is nothing coming back to tell it the adding of the product was successful. I am a total noob regarding ajax and javascript in general so debugging the whole thing would take ages for me. Did someone have similar problems with this new version and FF4 and was able to fix it? Thanks in advance, Kalle Quote Link to comment Share on other sites More sharing options...
meloniq Posted April 26, 2011 Share Posted April 26, 2011 So, i've payed a programmer, and he found the solution. Should be OK to just overwrite the old file, but i suggest a file compare just to be sure. Thank You very much Drako for solution! Quote Link to comment Share on other sites More sharing options...
Drako Posted April 26, 2011 Share Posted April 26, 2011 Thank You very much Drako for solution! You're welcome. Quote my contribution: Alex's Contributions Link to comment Share on other sites More sharing options...
VeganKalle Posted May 2, 2011 Share Posted May 2, 2011 It's even worse than before. I just noticed that the "new" version doesn't work in IE either, whereas the old one did. Is anyone able to help me get this working again? My sales have gone down remarkably, so I disabled the ajax shopping cart for now which is annoying for customers with other browsers who are used to the convenience of not scrolling all the way down after adding a product to the shopping cart. Quote Link to comment Share on other sites More sharing options...
sportstolen Posted May 8, 2011 Share Posted May 8, 2011 Thanks fort the "new jax_sc.js" but im sorry to say that is not working! Can you send an pm with your url so i can take a look if you got it to work. Quote Link to comment Share on other sites More sharing options...
sportstolen Posted May 8, 2011 Share Posted May 8, 2011 i have sent an email to the author of this contribution and asked if he could take a look at it. Quote Link to comment Share on other sites More sharing options...
Drako Posted May 8, 2011 Share Posted May 8, 2011 The solution is as it is, i paied for that and on my site it work. Check it here: www.drako.it Quote my contribution: Alex's Contributions Link to comment Share on other sites More sharing options...
sportstolen Posted May 8, 2011 Share Posted May 8, 2011 The solution is as it is, i paied for that and on my site it work. Check it here: www.drako.it Yes it works on your site, are you sure the programmer didnt change somewhere else? Maybe its because youre site is hosted on windows server and mine on linux server. I have ultimate seo urls installed i saw you didnt. maybe its something with that to. Its very strange because it use to be explorer that not working :) Somebody else got it working with drakos code? Many thanks for sharing!! I will to if i get it to work. Quote Link to comment Share on other sites More sharing options...
sportstolen Posted May 10, 2011 Share Posted May 10, 2011 lol! Check your version with jquery, i had 1.3.1.js and that was to old i guess, updated jquery and it worked with drakos code! Many thanks drako! really appreciate it! Quote Link to comment Share on other sites More sharing options...
liljankoski Posted May 11, 2011 Share Posted May 11, 2011 Ok, I didn't get it to work with Drakos code or an updated jquery, so I contacted a friend (http://vardevs.com/) who made a quick fix. He wanted to rewrite the whole code, but we settled with creating and changing ajax_sc.js to a big javascript instead. So all I needed to do was to replace ajax_sc.js. Hm, looks like there was to much code to write in a post, so I uploaded in Ajax Buy Now-archive: http://addons.oscommerce.com/info/4105 Hopefully it works for you too. See it working at Lilon.se Quote Link to comment Share on other sites More sharing options...
kalkal Posted May 12, 2011 Share Posted May 12, 2011 Neither of these solutions have worked for me! Any help would be greatly appreciated! Kal Quote Link to comment Share on other sites More sharing options...
sportstolen Posted May 12, 2011 Share Posted May 12, 2011 Neither of these solutions have worked for me! Any help would be greatly appreciated! Kal I use jquery 1.5.1 and applied drakos ajax.sc.js and that did the trick. Quote Link to comment Share on other sites More sharing options...
kalkal Posted May 13, 2011 Share Posted May 13, 2011 I use jquery 1.5.1 and applied drakos ajax.sc.js and that did the trick. Updating jquery seemed to fix it although i had to clear my cache like 5 times b4 it worked! Thanx! Kal Quote Link to comment Share on other sites More sharing options...
Simpel Posted May 16, 2011 Share Posted May 16, 2011 Great contribution. I got only a little problem... After installing I get the following symptoms. JavaScript code generated by backend is invalid! My whole page is loading in the shopping_cart box. In firefox I get 2 lines: after entering the buy command on the product_info.php the loading and the ok image passed POST /~oefening/index.php?option=com_oscommerce&osMod=ajax_shopping_cart.php&products_id=1&action=add_product&13055779418370-xml [HTTP/1.1 302 Found 2507ms] GET /~oefening/index.php?option=com_oscommerce&osMod=shopping_cart&Itemid=2& [HTTP/1.1 200 OK 1622ms] whole page load thanks in advance Quote Link to comment Share on other sites More sharing options...
Simpel Posted May 17, 2011 Share Posted May 17, 2011 in ajax.cs.js I had to change url = 'index.php?option=com_oscommerce&osMod=ajax_shopping_cart' + ( senddata.products_id ? 'products_id='+senddata.products_id+'&' : "" ) + 'action=add_product'; into url = 'index.php?option=com_oscommerce&osMod=ajax_shopping_cart' + '&format=ajax' + ( senddata.products_id ? 'products_id='+senddata.products_id+'&' : "" ) + 'action=add_product'; but JavaScript code generated by backend is invalid! still exists and instead of the whole page only the div from the shoppingcart.php is shown in the shoppingcart box instead of updating this box. Where should I look? Quote Link to comment Share on other sites More sharing options...
Simpel Posted May 18, 2011 Share Posted May 18, 2011 <?php /** AJAXBuyNow v2.0 author Weretennikoff Andrew aka Medreces [email protected] Released under the GNU General Public License */ // Ïîäêëþ÷àåì áèáëèîòåêó ïîääåðæêè. require_once('includes/classes/sybsys.php'); // Ñîçäàåì ãëàâíûé îáúåêò áèáëèîòåêè. // Óêàçûâàåì êîäèðîâêó ñòðàíèöû (îáÿçàòåëüíî! à ìîæåò ïîòîì?). $JsHttpRequest =& new Subsys_JsHttpRequest_Php(''); foreach( $_REQUEST as $key => $value) $HTTP_POST_VARS[$key]=$value; require('includes/application_top.php'); $navigation->remove_current_page(); // À âîò è êîäèðîâî÷êà!!!! $JsHttpRequest->setEncoding(CHARSET); require(DIR_WS_BOXES . 'shopping_cart.php'); require('includes/application_bottom.php'); ?> result into Fatal error: Cannot redeclare class shoppingCart in /public_html/includes/classes/shopping_cart.php on line 13 what's happening? Quote Link to comment Share on other sites More sharing options...
Simpel Posted May 18, 2011 Share Posted May 18, 2011 No problem on Safari on my end, everything seems to be cross browser compatible. I still can't get the flying effect working in the listing page (JavaScript code generated by backend is invalid, like betty88) Is there someone who knows this problem and solved it? Quote Link to comment Share on other sites More sharing options...
Simpel Posted May 19, 2011 Share Posted May 19, 2011 Is there someone who knows this problem and solved it? firefox says ' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: chrome://firebug/content/spy.js :: callPageHandler :: line 744" data: no] Should it be a wrong string/url in ajax.sc.js? Quote Link to comment Share on other sites More sharing options...
catch Posted May 22, 2011 Share Posted May 22, 2011 (edited) You're welcome. I use this and its working in Firefox and IE, but now its showing erro in IE, in the bottom of IE. The erro the like the following: Details about the error on the website Message: An unknown runtime error Line: 274 Character: 25 Code: 0 URI: http://www.mysite/ajax/javascript/ajax_sc.js I need help please. Edited May 22, 2011 by catch Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.