Search code examples
drupalahah

'Http error 0' when loading dynamic form elements in drupal 6, when an upload field has a file selected


I have a custom form implemented in a custom module in drupal 6. The form contains an upload field, a textfield and a select dropdown. When the dropdown fires a change event, two textfields are loaded dynamically below the dropdown through drupal AHAH. This is based largely on: http://drupal.org/node/331941 The form functions correctly.

However, if I happen to browse to a file from the upload field and then change the dropdown, I get the nasty 'http 0 error'. Note: I am not submitting the form. I am simply selecting the file to upload and then changing the dropdown to fire the change event. This problem is very much like: http://drupal.org/node/399676 However the solution provided in the same thread: http://drupal.org/node/399676#comment-1438662 doesn't work for me.

I changed the drupal_json call to drupal_get_js call as mentioned in the solution comment above, but I simply get an error alert containing some JSON.

I believe the problem is to do with the headers set by drupal_json as seen in the definition here: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_json/6

Any help much appreciated.


Solution

  • This turned out to be such a pervasive problem, that I simply moved to drupal 7 - upgrading all my custom modules to 7.

    I looked everywhere online and found many suggestions and none of them worked. If someone else ever comes across this problem, I highly suggest you go the same path and simply upgrade to d7. The d7 FAPI is so much more robust, especially where ajax based dynamic forms are concerned.