564e19b4db75608adf7d6273907a23ec553f42ca angie Mon Apr 30 17:23:51 2012 -0700 hgVarAnnogrator now stores querySpec in the cart, and uses the cart'squerySpec (if exists) to draw the page. It also does a reload when the user hits the back button, because the web browser forgets all AJAX updates and the cart has the latest state. It does synchronous AJAX to lookup the position before executing a query; that causes failure of ajax.js's setCartVars async GET, so in order to avoid a warning about network error, we ignore errors for setCartVars. (#6152) diff --git src/hg/js/ajax.js src/hg/js/ajax.js index 9a0d868..a3b24c9 100644 --- src/hg/js/ajax.js +++ src/hg/js/ajax.js @@ -141,36 +141,39 @@ } catch(e) { req = false; } } } if(debug) alert(url); if(req) { req.onreadystatechange = callBack; req.open("GET", url, true); req.send(); //req.send(""); } } -function setCartVars(names, values) +function setCartVars(names, values, errFunc) { // Asynchronously sets the array of cart vars with values if(names.length <= 0) return; + if (errFunc == null) + errFunc = errorHandler; + // Set up constant portion of url var loc = window.location.href; if(loc.indexOf("?") > -1) { loc = loc.substring(0, loc.indexOf("?")); } if(loc.lastIndexOf("/") > -1) { loc = loc.substring(0, loc.lastIndexOf("/")); } loc = loc + "/cartDump"; var hgsid = getHgsid(); var data = "submit=1&noDisplay=1&hgsid=" + hgsid; var track = getTrack(); if(track && track.length > 0) data = data + "&g=" + track; for(var ix=0; ix<names.length; ix++) { @@ -178,31 +181,31 @@ } var type; // We prefer GETs so we can analyze logs, but use POSTs if data is longer than a (conservatively small) // maximum length to avoid problems on older versions of IE. if((loc.length + data.length) > 2000) { type = "POST"; } else { type = "GET"; } $.ajax({ type: type, url: loc, data: data, trueSuccess: function () {}, success: catchErrorOrDispatch, - error: errorHandler, + error: errFunc, cache: false }); } function setCartVar(name, value) { // Asynchronously set a cart variable. setCartVars( [ name ], [ value ] ); } function setVarsFromHash(varHash) { // Set all vars in a var hash // If obj is undefined then obj is document! var names = [];