I could not make this module working. I installed the D6 dev. version. Enabled the modules Ajax, Ajax plugin comment, Ajax plugin thickbox, Ajax plugin - wysiwyg, Ajax ui. Then enabled all options on Ajax Settings. I tried to create a new Story content. I tried to save the form without the necessary Title information. I was expecting an error message without refreshing the page, but the error was message was shown after a page refresh.

CommentFileSizeAuthor
#14 drupalexample3.txt38.3 KBmcload
#5 drupalexample2.txt46.86 KBmcload
#2 drupalexample.txt45.41 KBmcload

Comments

brendoncrawford’s picture

Assigned: Unassigned » brendoncrawford
Category: support » bug

Mcload,

Can you post the html dump of the page containing the form you are trying to submit?

mcload’s picture

StatusFileSize
new45.41 KB

Attaced the html code of Story content creation page as a txt file.

brendoncrawford’s picture

Category: bug » support

mcload,

It looks like the ajax.js script is never being loaded into the document. Does your page.tpl.php have something like this:

print $scripts;

mcload’s picture

I am using the garland theme inside Drupal. I checked it now. It has that print $scripts command at page.tpl.php.
I am using "Optimize JavaScript files" option under Performance of Drupal. I thought that maybe it is related, but I did not see a change after disabling it.

mcload’s picture

StatusFileSize
new46.86 KB

Attaced the html source code after disabling "Optimize JavaScript files".

brendoncrawford’s picture

Looking at this...

<input type="submit" name="op" id="edit-submit" value="Save"  class="form-submit" />
<input type="submit" name="op" id="edit-preview" value="Preview"  class="form-submit" />

The Ajax module has not activated this form. Did you enable the story node in "admin/settings/ajax"?

mcload’s picture

Yes, I enabled all options on "admin/settings/ajax" including Story.

brendoncrawford’s picture

McLoad,

This is very odd. Perhaps you could provide the following:

1) Drupal version
2) PHP version
3) Operating system name and version
4) Web server name and version
5) Browser name and version

mcload’s picture

1) Drupal 6.10
2) PHP/5.2.5
3) CENTOS 5.2 i686
4) Apache/2.0.63
5) Firefox 3.08, IE 8

brendoncrawford’s picture

Can you try with only the ajax and ajax_ui module enabled?

Babalu’s picture

i have the same problem that ajax is not working on my site.
after enabling the module i have the problem that i can't add/create any new node/content type.
it shows me the message "access denied". but i'm the admin :)
with enabled content type at ajax settings and disabled content type at ajax settings

only the comment form is working

Babalu’s picture

the problem is still there when i'm now disable and uninstall the module
i can't add/create any new node/content type.
either access denied or submit event, video, group without everything i can do to create a node, just the title submit ...

brendoncrawford’s picture

Babalu,

Can you open a new bug for that?

mcload’s picture

StatusFileSize
new38.3 KB

I did some debugging to find the problem. I saw that the Story text box returns false with your function ajax_is_enabled($form). I printed the $form array and saw that $form does not have #ajax field. Attached the print_r output of $form as a text file.
Where is the code that inserts #ajax field to form? I can check there.

brendoncrawford’s picture

McLoad,

The ajax_ui module is reponsible for assigning the #ajax variable to the $form array. I must say that I am stumped.

mcload’s picture

OK. I did more debugging and found the reason. Normally it should work like this:

1) First, Ajax_ui module's ajax_ui_form_alter function alters the form and makes it Ajax-enabled by entering #Ajax information.
2)Then, Ajax module's ajax_form_alter function checks the form and adds script information if the form is ajax-enabled (form has #Ajax field)

I saw that in my Drupal installation, the order is opposite. Ajax module's ajax_form_alter function is run before Ajax_ui module's ajax_ui_form_alter function, so ajax_form_alter function can not find the #ajax information. Hook order is wrong.

mcload’s picture

Now, disabled and uninstalled Ajax_ui module. Then enabled Ajax_ui again. However, it did not solve the problem. Ajax_ui module is still processed after ajax module.

brendoncrawford’s picture

Mcload,

Nice catch! I will fix this right away. Thanks for finding this.

brendoncrawford’s picture

Status: Active » Fixed

Mcload,

This has been fixed in dev. Please allow up to 12 hours for dev to update. Also, be sure to run update.php after upgrading.

2c’s picture

Category: support » task

I'm experiencing a similar problem with 6.x-1.14 and 6.x-1.x-dev. Hopefully it is related.

The module has no effect when the form is presented and when the form is submitted the process appears non-Ajaxified as if the module is having no effect. However, the page that the form lands on is now stripped of ALL Ajax functionality, including modules not directly dependent on the AJAX.module! e.g. Fivestar, Magic Tabs etc. are rendered without Ajax functionality.

I've created a custom module with a MODULENAME_form_alter function for a form and added in the following:

$form['#ajax']['enabled'] = TRUE;

This affects the 'Submit' text of the forms submit button by changing it to 'Loading...' for a few seconds but then the form submits normally.

Do you have the HTML for a form properly working for this module so that I can try and isolate the problem?

brendoncrawford’s picture

Status: Fixed » Active

Phonydream2,

I have just added a fix to dev that may address this. Please wait up to 12 hours for the dev package to update. After installing the latest dev package, please run "/update.php". Let me know if this works. If it does not fix your problem, can you please open a new bug for this.

Thanks,
brendon

2c’s picture

Hi Brendon,

Thanks for this, it fixes my problem and specific use case IF I use the 'disable form redirect' functionality (is this a requirement for AJAX-ifying form submits?).

The problem I described in #20 above still persists if the 'disable form redirect' functionality is not employed. Come to think of it, I can't imagine why 'form redirect' functionality should be enabled in any situation where you want the form to submit via AJAX.

Thanks again, let me know if I can help.

brendoncrawford’s picture

I will have a look.

merlinofchaos’s picture

Brendon, your use of ajax_preprocess_page() in ajax.module is somewhat dangerous and makes assumptions that may not be true.

IMO, deleting that function and using this instead is much more foolproof:

/**
 * Implementation of hook_init().
 *
 * @return none
 *
 */
function ajax_init() {
  $p = drupal_get_path('module', 'ajax');
  drupal_add_js($p . '/jquery/jquery.a_form.packed.js', 'module');
  drupal_add_js($p . '/ajax.js', 'module');
}

For others having this issue, Panels Everywhere will cause this issue because it is taking over the page template and causing the preprocess not to run. There are probably any number of other odd ways that ajax.module's preprocess could fail.