Hi there.

Using Drupal 7.15. When I enable Clientside Validation, AJAX file uploads stop working, and return this error in a native browser alert: http://pastebin.com/tfEqHkTn (example when trying to "Delete" a previously uploaded image from a node).

It happens just after adding base Clientside Validation module component, without any of ther others components active. When I disable the module everything works fine. Error appears both in admin area and public forms that allow file uploads. Also happens both in testing (2) and production servers.

I'm using the AJAX component for other things (i.e: calendar month navigation) and it works flawlessly so I don't think it's an AJAX-related problem. File uploads work when AJAX is not used, sending the whole form instead of field-specific upload buttons.

Sadly I currently don't have the time to look at code and fix, but i'll be monitoring here if more information is needed. Sorry about that.

Comments

Jelle_S’s picture

Version: 7.x-1.34 » 7.x-1.x-dev
Status: Needs review » Active

Bug confirmed. Not sure what causes it. I'm looking in to it.

Jelle_S’s picture

Ok, very weird bug...

Do you by any chance have jquery_update enabled?

I had, and while it was enabled I got the error. Disabling either Clientside Validation or jquery_update 'fixed' the error.

I also found that commenting out hook_library_alter fixed the error (doesn't matter in which module I comment it out, works both for jquery_update as for Clientside Validation)

Setting "Use jquery.form.js version 3.09" to "No" at admin/config/validation/clientside_validation/general also fixes it.

Then I started digging a little deeper and commenting out just these lines in jquery_update_library_alter also fixes it:


  // Replace jQuery.
  jquery_update_jquery_replace($libraries, $cdn, $path, $min); 
  $libraries['jquery']['version'] = '1.5.2';

So for now you have these options:

  1. Set "Use jquery.form.js version 3.09" to "No" at admin/config/validation/clientside_validation/general
  2. Disable jquery_ui
  3. Comment out the lines I mentioned in jquery_update (not recommended)

Still not sure what is the actual cause of the error though...

attiks’s picture

If you're using jquery_update, which version of jquery: 1.5.2/1.7.1/1.8.2?

attiks’s picture

If you're using jQuery 1.5.2, this isn't going to work

Quote: "jquery-plugin-validation does not work with jquery 1.5; they did some really weird stuff with extend in their $.ajax shim. After refactoring this one weird line, it seems to work: phihag.de/2011/so/json/jquery.validate.js – phihag Feb 11 '11 at 14:30"

Try using the dev version of jquery_update

attiks’s picture

FYI: the ajax response is valid json, checked using http://jsonlint.com/

Jelle_S’s picture

Component: Code » Documentation
Priority: Major » Normal
Status: Active » Fixed

As of jquery_update 7.x-2.3 (there's an alpha1 release of 2.3 but it isn't listed on the project page) you can select the jquery version you want to use. If you select a version other than 1.5 everything should work again.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

steveoliver’s picture

In case it might help, see what the fix was for a similar issue we had with Relation Select (#1730262: AJAX errors using Views mini pager):

http://drupalcode.org/project/relation_select.git/blobdiff/d3b96273c8ff8...

X-Git-Url: http://drupalcode.org/project/relation_select.git/blobdiff_plain/d3b96273c8ff860272560996978de6f972bb33f8..314c5c6:/relation_select.module

diff --git a/relation_select.module b/relation_select.module
index 0aae465..7aaf8ff 100644
--- a/relation_select.module
+++ b/relation_select.module
@@ -897,6 +897,7 @@ function relation_select_ajax(){
   }
   // Keep a copy of ajax page state - need this to add css/js files bit it is removed in views_ajax()
   $ajax_page_state = $_POST['ajax_page_state'];
+  $ajax_iframe_upload = !empty($_POST['ajax_iframe_upload']);
   $commands = array();
   $views_ajax_commands = views_ajax();
   foreach($views_ajax_commands['#commands'] as $command){
@@ -906,8 +907,21 @@ function relation_select_ajax(){
   }
   // Re-define ajax_post_state before rendering to allow css/js files used by the view to be added
   $_POST['ajax_page_state'] = $ajax_page_state;
-  print ajax_render($commands);
-  exit();
+  $_POST['ajax_iframe_upload'] = $ajax_iframe_upload;
+
+  return array('#commands' => $commands, '#type' => 'ajax');
+}
+
+/**
+ * Implements hook_views_ajax_data_alter().
+ *
+ * This hook is called from views_ajax().
+ * views_ajax() rewrites $_GET['q'].
+ */
+function relation_select_views_ajax_data_alter($commands, $view) {
+  if ($_GET['q'] == 'relation-select/ajax' && isset($_GET['page']) && isset($_POST['ajax_iframe_upload'])) {
+    unset($_POST['ajax_iframe_upload']);
+  }
 }
 
 /**

In short, the ajax_iframe_upload $_POST variable is used for ajax (iframe) uploads, but broke our widget. hook_views_ajax_data_alter allowed us to temporarily remove the parameter until we were done with our process (and adding the parameter back once we were done).

A Romka’s picture

I was getting this same error, then switched jquery_update to use jquery 1.8 instead of 1.5 and now it's working fine.

Prague man’s picture

I have jquery 1.8 and the error still show:

Objevila se AJAX HTTP chyba.
Výsledný kód HTTP je: 200
Následují informace pro ladění.
Cesta: /file/ajax/field_fotogalerie/und/form-GIUW5g8bgbYgbm1BjfqUSA7RYWmo6w5WNfvPDadeAeM
Text stavu: parsererror
Text odpovědi:  [ {"command":"settings", "settings":{"basePath":"\u002F", "pathPrefix":"", "ajaxPageState":{"theme":"corolla", "theme_token":"qGLkPet1BTOXp69ZXEFw7JXqRkZ56tiHOOJGNNchWr8", "css":{"sites\u002Fall\u002Fmodules\u002Fcolorbox\u002Fstyles\u002Fdefault\u002Fcolorbox_style.css":1}, "js":{"sites\u002Fall\u002Fmodules\u002Fjquery_update\u002Freplace\u002Fjquery\u002Fjquery.min.js":1, "sites\u002Fall\u002Flibraries\u002Fcolorbox\u002Fcolorbox\u002Fjquery.colorbox-min.js":1, "sites\u002Fall\u002Fmodules\u002Fcolorbox\u002Fjs\u002Fcolorbox.js":1, "sites\u002Fall\u002Fmodules\u002Fcolorbox\u002Fstyles\u002Fdefault\u002Fcolorbox_style.js":1, "misc\u002Ftableheader.js":1}}, "colorbox":{"opacity":"0.85", "current":"{current} z {total}", "previous":"« Předchozí", "next":"Následující »", "close":"Zavřít", "maxWidth":"98%", "maxHeight":"98%", "fixed":true}, "ajax":{"edit-field-fotogalerie-und-0-remove-button":{"wrapper":"edit-field-fotogalerie-und-ajax-wrapper", "effect":"none", "progress":{"type":"throbber", "message":null}, "event":"mousedown", "keypress":true, "prevent":"click", "url":"\u002Ffile\u002Fajax\u002Ffield_fotogalerie\u002Fund\u002Fform-GIUW5g8bgbYgbm1BjfqUSA7RYWmo6w5WNfvPDadeAeM", "submit":{"_triggering_element_name":"field_fotogalerie_und_0_remove_button", "_triggering_element_value":"Odstranit"}}, "edit-field-fotogalerie-und-1-upload-button":{"wrapper":"edit-field-fotogalerie-und-ajax-wrapper", "effect":"fade", "progress":{"type":"throbber", "message":null}, "event":"mousedown", "keypress":true, "prevent":"click", "url":"\u002Ffile\u002Fajax\u002Ffield_fotogalerie\u002Fund\u002Fform-GIUW5g8bgbYgbm1BjfqUSA7RYWmo6w5WNfvPDadeAeM", "submit":{"_triggering_element_name":"field_fotogalerie_und_1_upload_button", "_triggering_element_value":"Nahrát"}}}, "tableDrag":{"edit-field-fotogalerie-und-table":{"edit-field-fotogalerie-und-weight":[ {"target":"edit-field-fotogalerie-und-weight", "source":"edit-field-fotogalerie-und-weight", "relationship":"sibling", "action":"order", "hidden":true, "limit":0} ]}}, "file":{"elements":{"#edit-field-fotogalerie-und-1-upload":"png,gif,jpg,jpeg"}}, "clientsideValidation":{"forms":{"auto-inzerat-zdarma-node-form":{"errorPlacement":"5", "general":{"errorClass":"error", "wrapper":"li", "validateTabs":0, "scrollTo":1, "scrollSpeed":"1000", "disableHtml5Validation":"1", "validateOnBlur":"1", "validateOnBlurAlways":"1", "validateOnKeyUp":"1", "validateOnSubmit":"1", "showMessages":"0", "errorElement":"span"}, "rules":{"title":{"required":true, "messages":{"required":"Nadpis inzerátu (krátce a výstižně, např.: Mazda 2 za super cenu) - je vyžadováno.", "maxlength":"Nadpis inzerátu (krátce a výstižně, např.: Mazda 2 za super cenu) field has to have maximum 255 values."}, "maxlength":255}, "name":{"maxlength":60, "messages":{"maxlength":"Autor field has to have maximum 60 values."}}, "date":{"maxlength":25, "messages":{"maxlength":"Napsáno dne field has to have maximum 25 values."}}, "field_znacka_model[und][hierarchical_select][selects][0]":{"required":true, "messages":{"required":"Značka a model - je vyžadováno.", "blacklist":"Značka a model - je vyžadováno."}, "blacklist":[ "label_0", "none", "_none", "label_0", "none", "_none" ]}, "field_znacka_model[und]":{"required":true, "messages":{"required":"Značka a model - je vyžadováno."}}, "field_karoserie_auta[und][hierarchical_select][selects][0]":{"required":true, "messages":{"required":"Karoserie - je vyžadováno.", "blacklist":"Karoserie - je vyžadováno."}, "blacklist":[ "label_0", "none", "_none", "label_0", "none", "_none" ]}, "field_karoserie_auta[und]":{"required":true, "messages":{"required":"Karoserie - je vyžadováno."}}, "files[field_fotogalerie_und_0]":{"required":true, "messages":{"required":"Fotogalerie - je vyžadováno."}}, "field_fotogalerie[und][0][alt]":{"maxlength":512, "messages":{"maxlength":"Alternativní text field has to have maximum 512 values."}}, "field_fotogalerie[und][0][title]":{"maxlength":1024, "messages":{"maxlength":"Nadpis field has to have maximum 1024 values."}}, "field_fotogalerie[und][1][alt]":{"maxlength":512, "messages":{"maxlength":"Alternativní text field has to have maximum 512 values."}}, "field_fotogalerie[und][1][title]":{"maxlength":1024, "messages":{"maxlength":"Nadpis field has to have maximum 1024 values."}}, "field_druh_vozidla[und]":{"required":true, "messages":{"required":"Druh vozidla - je vyžadováno.", "blacklist":"Druh vozidla - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_upresneni[und][0][value]":{"maxlength":"255", "messages":{"maxlength":"Upřesnění field has to have maximum 255 values."}}, "field_vykon_motoru[und][0][value]":{"required":true, "messages":{"required":"Výkon motoru - je vyžadováno.", "maxlength":"Výkon motoru field has to have maximum 10 values.", "digits_negative":"Výkon motoru field accepts only numbers."}, "maxlength":10, "digits_negative":true}, "field_stav_tachometru[und][0][value]":{"required":true, "messages":{"required":"Stav tachometru - je vyžadováno.", "maxlength":"Stav tachometru field has to have maximum 10 values.", "digits_negative":"Stav tachometru field accepts only numbers."}, "maxlength":10, "digits_negative":true}, "field_stk_do[und][0]":{"required":true, "messages":{"required":"STK platí (platila) do - je vyžadováno."}}, "field_stk_do[und][0][value]":{"required":true, "messages":{"required":"STK platí (platila) do - je vyžadováno."}}, "field_stk_do[und][0][value][month]":{"required":true, "messages":{"required":"Měsíc - je vyžadováno.", "blacklist":"Měsíc - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_stk_do[und][0][value][year]":{"required":true, "messages":{"required":"Rok - je vyžadováno.", "blacklist":"Rok - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_palivo[und]":{"required":true, "messages":{"required":"Palivo - je vyžadováno.", "blacklist":"Palivo - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_cena[und][0][value]":{"required":true, "messages":{"required":"Cena - je vyžadováno.", "maxlength":"Cena field has to have maximum 10 values.", "min":"Cena field has to be greater than 1.", "digits_negative":"Cena field accepts only numbers."}, "maxlength":10, "min":"1", "digits_negative":true}, "field_mena[und]":{"required":true, "messages":{"required":"Měna - je vyžadováno.", "blacklist":"Měna - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_rok_mesic_vyroby[und][0]":{"required":true, "messages":{"required":"Měsíc a rok výroby - je vyžadováno."}}, "field_rok_mesic_vyroby[und][0][value]":{"required":true, "messages":{"required":"Měsíc a rok výroby - je vyžadováno."}}, "field_rok_mesic_vyroby[und][0][value][month]":{"required":true, "messages":{"required":"Měsíc - je vyžadováno.", "blacklist":"Měsíc - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_rok_mesic_vyroby[und][0][value][year]":{"required":true, "messages":{"required":"Rok - je vyžadováno.", "blacklist":"Rok - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_pocet_dveri[und]":{"required":true, "messages":{"required":"Počet dveří - je vyžadováno.", "blacklist":"Počet dveří - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_objem_motoru[und]":{"required":true, "messages":{"required":"Zdvihový objem - je vyžadováno.", "blacklist":"Zdvihový objem - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "field_barva_auta[und]":{"required":true, "messages":{"required":"Barva auta - je vyžadováno.", "blacklist":"Barva auta - je vyžadováno."}, "blacklist":[ "_none", "_none" ]}, "menu[link_title]":{"maxlength":128, "messages":{"maxlength":"Nadpis odkazu menu field has to have maximum 128 values."}}, "path[alias]":{"maxlength":255, "messages":{"maxlength":"URL alias field has to have maximum 255 values."}}}}}, "general":{"usexregxp":0}, "groups":{"auto-inzerat-zdarma-node-form":{}}}}, "merge":true}, {"command":"insert", "method":"prepend", "selector":"head", "data":"\u003Clink type=\u0022text\u002Fcss\u0022 rel=\u0022stylesheet\u0022 href=\u0022http:\u002F\u002Fwww.auto-inzeraty.eu\u002Fsites\u002Fdefault\u002Ffiles\u002Fcss\u002Fcss_pWxHdE6qMSwPhi1rEYYcYG9Qt3jny3PMABJGVTZAxDc.css\u0022 media=\u0022all\u0022 \u002F\u003E\u000A", "settings":null}, {"command":"insert", "method":"prepend", "selector":"head", "data":"\u003Cscript src=\u0022http:\u002F\u002Fwww.auto-inzeraty.eu\u002Fsites\u002Fdefault\u002Ffiles\u002Fjs\u002Fjs_yYJY0iGhcJ8h-dt1kn2Je19yEF0UrBvUkZqO7ywsnto.js\u0022\u003E\u003C\u002Fscript\u003E\u000A\u003Cscript src=\u0022http:\u002F\u002Fwww.auto-inzeraty.eu\u002Fsites\u002Fdefault\u002Ffiles\u002Fjs\u002Fjs_CJpGrEbxfcCg_byy4AXfmbeJaElVTZ9KivYa_miNguY.js\u0022\u003E\u003C\u002Fscript\u003E\u000A", "settings":null}, {"command":"insert", "method":"replaceWith", "selector":null, "data":"\u003Cdiv id=\u0022edit-field-fotogalerie-und-ajax-wrapper\u0022\u003E\u003Cfieldset id=\u0022edit-field-fotogalerie-und\u0022 class=\u0022form-wrapper\u0022\u003E\u003Clegend\u003E\u003Cspan class=\u0022fieldset-legend\u0022\u003EFotogalerie\u003C\u002Fspan\u003E\u003C\u002Flegend\u003E\u003Cdiv class=\u0022fieldset-wrapper with-legend\u0022\u003E\u003Cdiv class=\u0022fieldset-description\u0022\u003EU typu inzerátu ZDARMA jsou povolené max. 3 fotografie.\u003C\u002Fdiv\u003E\u003Ctable id=\u0022edit-field-fotogalerie-und-table\u0022 class=\u0022sticky-enabled\u0022\u003E\u000A \u003Cthead\u003E\u003Ctr\u003E\u003Cth\u003EInformace o souboru\u003C\u002Fth\u003E\u003Cth\u003EVáha\u003C\u002Fth\u003E\u003Cth\u003EOperace\u003C\u002Fth\u003E \u003C\u002Ftr\u003E\u003C\u002Fthead\u003E\u000A\u003Ctbody\u003E\u000A \u003Ctr class=\u0022draggable odd\u0022\u003E\u003Ctd\u003E\u003Cdiv class=\u0022image-widget form-managed-file clearfix\u0022\u003E\u003Cdiv class=\u0022image-widget-data\u0022\u003E\u003Cspan cl