Advanced Search not working

Bauer

Well-Known Member
I have not been able to get Advanced search working in lists for a while. (I don't use this feature in any frontend lists in my project, so debugging the problem hasn't been a high priority.)

I don't know when this started, or if it's just a PHP7 or Chrome thing, but when I click the 'Advanced search' link, the window pops up with just the heading and a 'Loading' spinner - and I get this fatal error message in the js console...
XMLHttpRequest cannot load https://www.mydomain.com/index.php?...1d34ff3e46b677806f&listref=133_com_fabrik_133. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://mydomain.com' is therefore not allowed access.
jquery.min.js:5 XHR failed loading: POST "https://www.mydomain.com/index.php?...1d34ff3e46b677806f&listref=133_com_fabrik_133".send @ jquery.min.js:5m.extend.ajax @ jquery.min.js:5Fabrik.Window.Class.loadContent @ window.js:401e.extend.$owner @ mootools-core.js:38Fabrik.Window.Class.makeWindow @ window.js:178e.extend.$owner @ mootools-core.js:38Fabrik.Window.Class.initialize @ window.js:84(anonymous function) @ mootools-more.js:27e.extend.$owner @ mootools-core.js:38(anonymous function) @ mootools-core.js:37Fabrik.getWindow @ window.js:39(anonymous function) @ listfilter.js:2m.event.dispatch @ jquery.min.js:4r.handle @ jquery.min.js:4
After reading-up on this, it looks like this is a browser security feature to prevent cross-domain requests.
https://jvaneyck.wordpress.com/2014/01/07/cross-domain-requests-in-javascript/

The solution is to remove the "https://mydomain.com" from the request.
This can be done at line 331 of ./components/com_fabrik/models/list-advanced-search.php.
Changing...
PHP:
$url = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $this->package .          &format=partial&view=list&layout=_advancedsearch&tmpl=component&listid='
            . $table->id . '&nextview=' . $this->app->input->get('view', 'list');
...to...
PHP:
$url = '/index.php?option=com_' . $this->package .            '&format=partial&view=list&layout=_advancedsearch&tmpl=component&listid='
            . $table->id . '&nextview=' . $this->app->input->get('view', 'list');
fixes the problem.

I'd create a PR at github but I've been scared away from doing that, less I get accused of 'breaking' something.:rolleyes:
But if someone is going to fix this, they should also be aware that the same code is used at line 293 of ./components/com_fabrik/models/visualization.php.
 
Last edited:
Back
Top