I'm a complete novice when it comes to web development, but I'm going through the examples in the 2nd edition of the Agile Web Development With Rails book and have hit a snag.
I've added the AJAX code to update the shopping cart immediately upon pressing Add To Cart on one of the line items. However, as soon as I click Add To Cart a download menu pops up. It does not seem to matter if I actually download the file or if I cancel -- I can refresh the page and the shopping cart does indeed get updated.
The name of the file to be downloaded is a large number (e.g. 300000000 ) that seems to be tied to the item I select. The downloaded file contents is as follows:
try { Element.update("cart", "<div class=\"cart-title\">Your Cart</div>\n<table>\n \n <tr id=\"current_item\">\n\n <td>4×</td>\n <td>Pragmatic Unit Testing (C#)</td>\n <td class=\"item-price\">$111.00</td>\n</tr>\n \n <tr class=\"total-line\">\n <td colspan=\"2\">Total</td>\n <td class=\"total-cell\">$111.00</td>\n </tr>\n</table>\n\n<form method=\"post\" action=\"/store/empty_cart\" class=\"button-to\"><div><input type=\"submit\" value=\"Empty cart\" /></div></form>"); $("current_item").visualEffect("highlight", {"startcolor": "#88ff88", "endcolor": "#114411"}); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"cart\", \"<div class=\\"cart-title\\">Your Cart</div>\n<table>\n \n <tr id=\\"current_item\\">\n\n <td>4×</td>\n <td>Pragmatic Unit Testing (C#)</td>\n <td class=\\"item-price\\">$111.00</td>\n</tr>\n \n <tr class=\\"total-line\\">\n <td colspan=\\"2\\">Total</td>\n <td class=\\"total-cell\\">$111.00</td>\n </tr>\n</table>\n\n<form method=\\"post\\" action=\\"/store/empty_cart\\" class=\\"button-to\\"><div><input type=\\"submit\\" value=\\"Empty cart\\" /></div></form>\");\n$(\"current_item\").visualEffect(\"highlight\", {\"startcolor\": \"#88ff88\", \"endcolor\": \"#114411\"});'); throw e }
Any idea what is happening here, and more importantly, how to fix it?
I should mention that even though the book recommends downloading the Edge Rails version, I am using the current version that comes with InstantRails. I suppose that could have something to do with it.