Receiving the following error:

An error occurred while attempting to process /D7/system/ajax: undefined is not a function (evaluating 'this.indexOf(item)')

when changing cart values that are affected by ajax (coupon codes, saved address selection, shipping calculations, etc). I thought it was related to the theme I was using, but I tried and it also occurs using Bartik or Garland stock themes.

I've found this error in three year old posts but nothing recent, but it is pervasive and appears in multiple browsers.

Thoughts anyone?

Comments

TR’s picture

A search of the issue queues show that this might be related to the jQuery Update module, if you happen to have that installed. See #2266303: Update jquery.form.js and try out the patch in that issue.

Regardless, it seems that something is wrong with your core Drupal Ajax malfunctioning - this doesn't seem to have anything to do with Ubercart.

thechraveler’s picture

Hi yes I thought it was my theme, but the error appears in core themes as well as my contributed theme I am using, and it only appears in the checkout process, and not in ajax operations anywhere else on the site. I tried installing JQuery Update, and tried the fix above, but the error still appears in checkout. I switched to Bartik theme and it didn't appear at first, but then it did...

thechraveler’s picture

appears in my contrib theme, Bartik, and Stark, but not in Garland or Seven core themes...

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

Personally I haven't seen this error before, we will need steps to reproduce it from a fresh install, or possibly a link to a site that exhibits the problem, in order to be able to diagnose it. The error message alone does not contain enough detail to debug it further.

AlfTheCat’s picture

I'm experiencing this error as well, it happens on checkout when I try to change the country in the customers' address, or at any action that dynamically validates/ alters a form through ajax (such as trying to use a previously stored address). I'm actually experiencing this in drupal commerce too but for ubercart I'm getting the following error in the server log:

PHP Fatal error:  Call to undefined function uc_cart_checkout_form_validate() in /var/aegir/platforms/****/includes/form.inc on line 1513, referer: http://****.com/cart/checkout
TR’s picture

@AlfTheCat: That function is in uc_cart/uc_cart.pages.inc, and has been for many many years. You should verify that it's there on your site too, to make sure your files haven't been corrupted. If it's there, that indicates a pretty significant error in the Drupal core loading system, possibly due to some aggressive caching module you're using, or to something in the Aegir platform, but it doesn't indicate a problem with anything Ubercart has any control over.

AlfTheCat’s picture

@TR,

Thanks for the reply. The files look ok, the function is there.

I do have caching mecahnisms running on this particular site but on the drupal commerce one I don't, other that that it's running on the same server (which has memcache and APC installed). On a dev server though, using the same server config, I don't get this issue.

I've used the cacheexclude module to exclude /cart/checkout from being cached and I've throrouhly cleared caches and manually truncated the cache and all cache_* tables in the database. No luck.

Is there a way I can turn ajax off on this address form in Ubercart? I know drupal commerce allows this as it uses the address_field module but in ubercart I can't find any option. This site is dealing with non-shippable goods so I *could* just turn off address information collection all together to restore functionality but I'd rather not do that.

If it's of any help, running form inspector in Chrome tells me this when I try to manipulate the checkout form by selecting a different country or previously saved address:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) http:/****/system/ajax
and

POST http://****.com/system/ajax 500 (Internal Server Error) jquery.min.js?v=1.8.2:2send jquery.min.js?v=1.8.2:2p.extend.ajax jquery.min.js?v=1.8.2:2a.fn.ajaxSubmit jquery.form.min.js?v=2.69:11Drupal.ajax.eventResponse ajax.js?v=7.31:251Drupal.ajax.eventResponse panels_ipe.js?nf0hgt:431(anonymous function) ajax.js?v=7.31:178p.event.dis (and should you wonder, yes I patched this version of drupal with the security fix :)

AlfTheCat’s picture

As it turns out, not collecting address information is not a valid workaround, at least when using paypal_wps for collecting payment. It creates a problem when an existing customer has previously filled out his or her address (which now can't be changed anymore because of the ajax error). Even with address collection disabled, address information is still sent to Paypal but this time its "unknown, [site default store country]. When the country in the buyers paypal account doesnt match the default country programatically set during checkout, Paypal will throw an error saying:

We're sorry, PayPal doesn't allow residents of FOO to ship purchases to BAR

So I had to switch to paypal express checkout but that doesn't appear to be working for recurring payments #2237071: Is Paypal Express supported in 7.x?

This is becoming very messy. And again, the weird thing is I have the same issue with drupal commerce's address collection field, except there I can configure it to not dynamically load in the way it does by default.

I don't have any other ajax issues, views and attribute selections, all working fine.

AlfTheCat’s picture

Title: ubercart checkout ajax errors » Panels on ubercart checkout produces ajax errors

Okay guess what (I'm amazed I actually found this!!):

I had brought the checkout under the control of panels, through pm_existing_pages. And this caught my eye in the chrome dev tools debug output I pasted before:
panels_ipe.js?nf0hgt:431(anonymous function) ajax.js?v=7.31:178p.event.dis

So I disabled the panels variants and poof! The address form worked again. This same solution ended up working for the drupal commerce issue as well. I did also try to go through other Jquery versions just to see if 1.7, 1.8, 1.9 would be a culprit, but no. It clearly was Panels.

So, I'm not really sure where to go with this, if it's a ctools/ pm / ipe issue or something else related to "how drupal loads things" as TR remarked or if its indeed UC and drupal commerce related or something else entirely. I'm just very happy I got this resolved.

I think at the very least the title should be changed

AlfTheCat’s picture

Status: Postponed (maintainer needs more info) » Active

Changing to active as well, as I think the above would fit the information request of the maintainer. Sorry for the multitude of comments.

thechraveler’s picture

I am using panels, but only for a homepage and nothing in ubercart. when I check the box next to "Update product display based on customer selections" at admin/store/settings/products, and the product page tries to calculate the display price based on any selected attributes, it throws the same error...

thechraveler’s picture

I also get the error if I try and enter a discount code (I am using UC Coupon module) in checkout. If I apply a code on the /cart page, it reloads the page and there is no error.

AlfTheCat’s picture

My issue is specific to the dynamic form rebuilding when changing countries. The panels or ipe conflict happens only there, for both drupal commerce and ubercart. Everything else is working fine. Mine I suppose is a different one from the op.

The last two comments seem to indicate a more general problem. Ajax or server related?

TR’s picture

Status: Active » Closed (outdated)