Hello!

I see the following error when trying to use finder with AJAX turned on.

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: 
Fatal error:  Call to undefined function finder_form_validate() in Z:\home\test.ru\www\includes\form.inc on line 1414

Reproduction
1. Install Drupal 7.8 and today's (Sep-07, 2011) finder
2. Activate Finder & Finder Node & Finder text modules
3. Add several content pages (I have added 5)
4. Add a node finder with Text field to search through node titles
5. Mark "Use Ajax on submit button"
6. Go to /finder/1
7. Insert any text and press "Find" button

Here is my finder (just in case)

array(
  'finder_id' => '1',
  'base' => 'node',
  'title' => 'Finder 1',
  'description' => '',
  'path' => 'finder/1',
  'block' => '0',
  'settings' => array(
    'form_on_page' => 1,
    'form' => array(
      'prefix' => array(
        'value' => '',
        'format' => 'filtered_html',
      ),
      'suffix' => array(
        'value' => '',
        'format' => 'filtered_html',
      ),
      'button_text' => 'Find',
      'go_text' => 'Go',
    ),
    'advanced' => array(
      'no_results' => array(
        'no_results' => 'There are no results to display',
      ),
      'filter' => 0,
      'validate_empty' => 0,
      'submission' => 1,
      'ajax' => 1,
      'ajax_effect' => 'none',
      'ajax_remote' => 0,
      'element_combination' => '0',
      'pager' => '10',
      'goto' => '',
      'hide_args' => 0,
      'arg_sep' => ',',
      'empty_symbol' => '',
      'show_links' => 1,
      'show_admin_links' => 1,
      'cache_finder_find' => '0',
    ),
  ),
  'elements' => array(
    '0' => array(
      'finder_element_id' => '1',
      'finder_id' => '1',
      'element' => 'text',
      'title' => 'Заголовок',
      'weight' => '0',
      'settings' => array(
        'form' => array(
          'description' => '',
          'prefix' => array(
            'value' => '',
            'format' => 'filtered_html',
          ),
          'suffix' => array(
            'value' => '',
            'format' => 'filtered_html',
          ),
          'default_value' => '',
          'required' => 0,
          'field_prefix' => '',
          'field_suffix' => '',
          'maxlength' => '',
          'minlength' => '',
          'size' => '',
          'rows' => '0',
        ),
        'choices' => array(
          'field' => array(
            'node.title' => 'node.title',
          ),
          'node_types' => array(
            '' => '',
          ),
          'published' => 1,
        ),
        'advanced' => array(
          'delimit' => '',
          'field_combination' => '0',
          'value_combination' => '0',
          'nesting_order' => '0',
          'match' => 'c',
        ),
      ),
      'element_handler' => array(
        '#title' => 'Text',
        '#module' => 'finder_text',
      ),
      '#_finder_object' => '1',
    ),
  ),
  'elements_index' => array(
    '1' => 0,
  ),
  'base_handler' => array(
    '#title' => 'Node finder',
    '#module' => 'finder_node',
  ),
  'admin_links' => array(
    'finder/1' => 'View \"Path\"',
    'admin/structure/finder/1/edit' => 'Edit',
  ),
  'links' => array(),
  '#_finder_object' => '1',
)

Asking for any help :)

Comments

Georgii’s picture

Version: 7.x-1.x-dev » 7.x-1.5
danielb’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Active » Fixed

Good on ya, thanks.

Georgii’s picture

Status: Fixed » Active

@danielb,

Thanks for looking at this so quickly but unfortunately I fail to test this successfully. I have exactly the same error when I press "Find" button.

* Cache of Drupal and browser was cleared each time I was testing.

danielb’s picture

Status: Active » Fixed

Marking as fixed because the date of your post #3 precedes the date on the dev snapshot.

danielb’s picture

Status: Fixed » Active

actually i got the error just then
strange
I did use form_load_include(), but I am suspecting this doesn't actually make sense the way it's done :/

danielb’s picture

I think I'm supposed to use form_load_include() instead of module_load_include() when I include the form in finder_view().
I think.

danielb’s picture

No that's not right. I was using it right the first time, but the path was slightly wrong.

Anyway fixing this seems to cause some other issue, so I'm not committing anything yet.

Georgii’s picture

@danielb
Thank you for working on this while keeping community informed :)
I wish I could help but my experience in Drupal programming is too low to dig inside such an advanced module like Finder.

danielb’s picture

this is not going well :/

danielb’s picture

I don't know, I get some bizarre error that doesn't actually look like an error when I try to use ajax. Rewritten it three times and nothing works.

It's committed if you want a look.
Do you get an error like:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /(yoursite)/finder_ajax/(finder id)/(finder url)
StatusText: OK
ResponseText:
(Your finder) | (Your site)
@import
url("http:// some shit")
@import
url("http:// other shit")
@import
url("http:// etc...")
@import
url("etc...")
.
.
etc...

Georgii’s picture

@danielb
Sure, I'd like to look at that but it seems that I'm not able to download the latest commit.
I don't have access to Git and the latest 7.x-dev version is dated as Sep-100 for me.

What should I do do get the version with your latest commits?

danielb’s picture

wait 12 hours :/
(FYI though; everyone has access to git, just follow the 'version control' link on the finder project page.)

Georgii’s picture

OK, I will wait and come back with results.
(Thanks! It looks like I have to install some SW to execute those commands and get the latest commits instantly. So I wait 12 hrs.)

Georgii’s picture

I get exactly the same error as you described. Looks like it tries to print out the page content: I see CSS inclusions, links from blocks etc.

danielb’s picture

yeah that's what I suspect is happening

but if I go to the path: finder_ajax/(finder id)/(finder/path/here)

It seems to print legit JSON output without all that other stuff? Although I never checked the source.

Kind of frustrating because I tried to do pretty much the same thing as I did in Drupal 6, and it just didn't work...

Georgii’s picture

That's right. I see
{"status":true,"data":"\u003cdiv class=\"finder-view-1 finder-view\"\u003e\u003cdiv id=\"finder-admin-links-1\"\r\n on that page

For me it looks like some headers here are doing their bad job. I'll take a look

Georgii’s picture

This is what I have digging deep into POST query of a finder (using FireBug)

The request headers

Host			URL.ru
User-Agent		Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0
Accept			application/json, text/javascript, */*; q=0.01
Accept-Language		ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding		gzip, deflate
Accept-Charset		windows-1251,utf-8;q=0.7,*;q=0.7
DNT			1
Proxy-Connection	keep-alive
Content-Type		application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With	XMLHttpRequest
Referer			http://URL.ru/poisk
Content-Length		6292
Cookie			has_js=1;
			SESS368da9844b34...-5b5cpWrj4; Drupal.toolbar.collapsed=0
Pragma			no-cache
Cache-Control		no-cache

There is nothing suspicious to me.

Here is the POST content parsed

2				test
_triggering_element_name	find
_triggering_element_value	Find
ajax_html_ids[]			omega-media-query-dummy
ajax_html_ids[]			skip-link
ajax_html_ids[]			region-page-top
ajax_html_ids[]			overlay-disable-message
ajax_html_ids[]			overlay-profile-link
ajax_html_ids[]			overlay-dismiss-message
ajax_html_ids[]			toolbar
ajax_html_ids[]			toolbar-home
ajax_html_ids[]			toolbar-user
ajax_html_ids[]			toolbar-menu
ajax_html_ids[]			toolbar-link-admin-dashboard
ajax_html_ids[]			toolbar-link-admin-content
ajax_html_ids[]			toolbar-link-admin-structure
ajax_html_ids[]			toolbar-link-admin-appearance
ajax_html_ids[]			toolbar-link-admin-people
ajax_html_ids[]			toolbar-link-admin-modules
ajax_html_ids[]			toolbar-link-admin-config
ajax_html_ids[]			toolbar-link-admin-reports
ajax_html_ids[]			toolbar-link-admin-help
ajax_html_ids[]			edit-shortcuts
ajax_html_ids[]			page
ajax_html_ids[]			section-header
ajax_html_ids[]			zone-user-wrapper
ajax_html_ids[]			zone-user
ajax_html_ids[]			region-user-first
ajax_html_ids[]			region-user-second
ajax_html_ids[]			block-system-user-menu
ajax_html_ids[]			zone-branding-wrapper
ajax_html_ids[]			zone-branding
ajax_html_ids[]			region-branding
ajax_html_ids[]			logo
ajax_html_ids[]			zone-menu-wrapper
ajax_html_ids[]			zone-menu
ajax_html_ids[]			region-menu
ajax_html_ids[]			main-menu
ajax_html_ids[]			section-content
ajax_html_ids[]			zone-content-wrapper
ajax_html_ids[]			zone-content
ajax_html_ids[]			breadcrumb
ajax_html_ids[]			region-sidebar-first
ajax_html_ids[]			block-system-navigation
ajax_html_ids[]			block-userpoints-1
ajax_html_ids[]			region-content
ajax_html_ids[]			main-content
ajax_html_ids[]			page-title
ajax_html_ids[]			block-system-main
ajax_html_ids[]			finder-page-1
ajax_html_ids[]			finder-page-1-wrapper
ajax_html_ids[]			finder-admin-links-1
ajax_html_ids[]			finder-form-1
ajax_html_ids[]			edit-2
ajax_html_ids[]			edit-2-autocomplete
ajax_html_ids[]			edit-2-autocomplete-aria-live
ajax_html_ids[]			edit-submit
ajax_html_ids[]			region-sidebar-second
ajax_html_ids[]			block-block-3
ajax_html_ids[]			section-footer
ajax_html_ids[]			zone-footer-wrapper
ajax_html_ids[]			zone-footer
ajax_html_ids[]			region-footer-second
ajax_html_ids[]			block-block-1
ajax_page_state[css][misc...	1
ajax_page_state[css][misc...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][modu...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][site...	1
ajax_page_state[css][wide...	1
ajax_page_state[css][wide...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][misc/...	1
ajax_page_state[js][modul...	1
ajax_page_state[js][modul...	1
ajax_page_state[js][modul...	1
ajax_page_state[js][sites...	1
ajax_page_state[js][sites...	1
ajax_page_state[js][sites...	1
ajax_page_state[js][sites...	1
ajax_page_state[theme]		site_theme
ajax_page_state[theme_tok...	5YrKpT9FL_C2dXejbUBmooi11ND1gKRudFMyc4ApBns
form_build_id			form-H_qZB4qsmcAYhTBa3n0bc1Dfoag8FyzucI9WnUA1JPw
form_id				finder_form_1
form_token			HQz6NCBUJTLy4neFy_pl1bpMVkdKv2yRj7eJm9vtZvk

Can it help somehow?

danielb’s picture

Title: Call to undefined function finder_form_validate() » AJAX not working at all

If there is useful info there, then I lack the knowledge to use it, sorry.

The thing about the headers might be a potential lead. I guess I could try forcing them, I think i've seen that done before.

flipolopo’s picture

I have same ajax errors on all drupal ajax supported modules and it helps me?
http://drupal.org/node/1067750#comment-4941822

rdiazjokyo’s picture

subscribe

danielb’s picture

Priority: Normal » Major
danielb’s picture

I have tried to do this ajax a hundred different ways, it's not working...

kclarkson’s picture

Any update on the fix for this error?

I am getting the same AJAX error and I have downloaded the most recent dev. version of this module.

Thanks,

danielb’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

This continues to be a problem in the new version. :(
I cannot find an example of using FAPI #ajax 'path' in Drupal 7 anywhere.

r13ose’s picture

Has there been any updates on this as this has been 3 months since the last comment was made. I have looked around and there are pages with information about what you want and you can read them and figure this out. If this is something where you are stuck on please let the community know where and we can help you figure this out.

danielb’s picture

I am stuck on it. Since I don't understand what's wrong, I can't elaborate. An example of how to use ajax with a custom path would be great.
This issue is somewhat of a release blocker for 7.x-2.x.

beanluc’s picture

Regarding #ajax['path']

This property is infrequently used in Drupal 7 and higher, because it is set automatically if using the #ajax['callback'] property

From http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#ajax_path

danielb: Consider looking for example implementations of the callback property rather than looking forexample implementations of the page property. In fact, that very page shows such an example, under #ajax['callback'].

I haven't seen any suggestion that you might need a custom path, which is probably the *only* reason someone might want to use ['path'] instead of ['callback'].

Hope this helps.

danielb’s picture

When this issue was created, Finder did use #ajax['callback'].

beanluc’s picture

Okay. I was just responding to the comment about not being able to find an example of #ajax['path'] in D7.

I also was sort of mentioning the matter of a custom path. Are you sure you need it?

danielb’s picture

No I am not sure. Whatever works I guess.

danielb’s picture

This issue is doing my head in, I have spent countless hours on it. I can easily create a simple module that does an ajax submit, but it doesn't work in finder no matter what I try.
The basic description of the problem is that the 'http response' from system/ajax is the entire HTML for the results page (with results worked out correctly!) including all the template headers/footers - everything, even if the ajax callback is set to return a dummy value, AND EVEN WHEN THE CALLBACK FUNCTION DOES NOT EXIST AT ALL.

danielb’s picture

ok writing that post made me realise it was the submit function causing the problems, it does stuff *sigh*

danielb’s picture

The functions finder_form_submit(), finder_form_state(), and possibly finder_form_goto() are not designed well, were initially written before a lot of features were added which have been hacked in, and I avoided changing them too much during the D7 port to avoid surprises. It seems now the current state of the functions is more trouble than it's worth. These functions need to be reconsidered and/or rewritten with the following things in mind:

- The normal way a typical drupal form sends information to create a follow-up page.
- Avoid using a redirect to go to the results page
- Finders with url args
- Finders without url args
- Finders with ajax
- Finders with multiple step forms (future functionality)

I think I will try to base finder forms on ctools_dependant and the ctools form wizard and not rely on the url as a primary method of communicating information between instances of finder pages - it should only be a backup method like when you give your results link to a friend to look at.

Anonymous’s picture

suscribe.

I have the same error, after a fresh install on drupal 7. I have an AJAX error on every link I click on.
The module cannot be correctly used. ;'-(

danielb’s picture

You don't need to reply to a thread to subscribe to it. Saying stuff here at this point can only make things worse.

danielb’s picture

I've given up on improving the stuff I said in #33 because "typical drupal form sends information to create a follow-up page" is not a concept that exists in drupal at all, which I guess is why I wrote it this convoluted way to begin with.

I've fixed the error and ajax returns stuff correctly, however when using ajax no results are calculated and I can't figure out why.

danielb’s picture

getting a little closer, but I gotta go cook some salmon
wish there was an issue queue for that

danielb’s picture

Status: Active » Fixed

got it working now

Status: Fixed » Closed (fixed)

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