CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • ajax call from case create form returns the case dashboard??
Pages: [1] 2

Author Topic: ajax call from case create form returns the case dashboard??  (Read 1425 times)

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
ajax call from case create form returns the case dashboard??
June 11, 2014, 12:52:54 pm
I'm trying to get some drupal data to display on the case create form. I use ajax to execute a script that gets the data ok, but firebug tells me the response is the case dashboard page. This would appear to be a security problem. Any solutions?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: ajax call from case create form returns the case dashboard??
June 11, 2014, 01:56:22 pm
You might need to send the key parameter in the call.  See {crmKey} in some existing code in the templates, like CRM/Case/Form/CaseView.tpl  or CRM_Core_Key::get()

But not sure if that's the exact problem here. Assuming you're using 4.0.7 based on the profile.

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 12, 2014, 06:42:05 am
The site is using 4.4.5.  I'm not calling the api, rather ajax is calling a php script to fetch drupal data. The api just gets civicrm data. I would have to write an api extension and would rather not do that.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: ajax call from case create form returns the case dashboard??
June 12, 2014, 10:29:32 am
Is this php inside a drupal module or a standalone script?

If it's a standalone script then it might be because of which folder the script is in. Civi might be trying to route the url through its controller.

If it's in a drupal module you probably want to do something like this, where you set up a menu callback and output drupal_json: https://drupal.org/node/305747

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 13, 2014, 07:36:05 am
It's a standalone script. What folder should it be in?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: ajax call from case create form returns the case dashboard??
June 13, 2014, 09:06:26 am
Mostly depends on what kind of access you want to allow and your existing folder layout, and what you've already got in your .htaccess and other web config. Try putting it in the web root to start just to see if that fixes it.

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 13, 2014, 12:26:10 pm
That's where it is now.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: ajax call from case create form returns the case dashboard??
June 13, 2014, 02:08:31 pm
Are you able to post some of the code in the script and also the code that makes the ajax call?

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 15, 2014, 09:02:10 am
If I put the ajax code in a non civicrm page, it works just fine. So I guess it's a permission thing. So, I wrote an api extension that gets the data and the data now shows up on the civicrm page. However, the autocomplete text field that I added to display the data doesn't display anything.  I tried making the autocomplete source local data just for testing and still no display. So civicrm is preventing the autocomplete from displaying???

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: ajax call from case create form returns the case dashboard??
June 15, 2014, 10:17:47 am
Quote from: dlats on June 15, 2014, 09:02:10 am
  So civicrm is preventing the autocomplete from displaying???

Drupal and CiviCRM often use different versions of jQuery and a different name for the jQuery function. CiviCRM uses cj for example. Check which jQuery toolbox you are using--if it's a CiviCRM field, then you should use the CiviCRM jQuery tools.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 15, 2014, 11:49:02 am
I'm using cj on the civicrm case create form. JQueryUI is version 1.9 (according to the page source). Ny code looks like

cj(document).ready(function(){

  cj("#type_dog_name").autocomplete( {
     source: ["Fido","Fideaux","Fidough"]
  });

}); // doc ready

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: ajax call from case create form returns the case dashboard??
June 15, 2014, 01:15:21 pm
On the surface, that code looks OK. I have code similar to this on a CiviCRM 4.4.5 site:

Code: [Select]
jQuery(document).ready(function($){
  cj( '#current_employer').autocomplete( '/get_employer_ajax', {
     mustMatch: true
  });
});

and for the outermost block, I used jQuery not cj. Perhaps try that.

Beyond that, I'm not sure--we would probably have to see the page to understand better.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 15, 2014, 01:32:47 pm
jQuery(document).ready doesn't work either.
The field id="type_dog_name" was added to the case create form via a module implementing hook_civicrm_buildForm() .

$form->add('text', 'type_dog_name', ts(''));

A custom template was modified to include the added field. Indeed the field displays on the case create form.

The js was added using js injector and does appear in the page source.

There is another autocomplete field on the page which works just fine. (std one for contact). The site that I testing on uses civicrm 4.4.3.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: ajax call from case create form returns the case dashboard??
June 16, 2014, 03:23:14 am
It's almost impossible for us to guess any further at what might be the problem. We would have to see the full page.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: ajax call from case create form returns the case dashboard??
June 17, 2014, 06:32:30 am
I decided to upgrade to 4.4.5. Running the upgrade seemed to work except at the end when I got this error message;

"Queue runner must be configured before execution."

I was getting this error before the upgrade whenever there was db access (ie install extensions). I tried deleting template_c file, clearing the cache and using php 5.3 and 5.5 instead of 5.4. These had no effect, still get the error.

II suspect that this may have something to do with the current autocomplete problem.

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • ajax call from case create form returns the case dashboard??

This forum was archived on 2017-11-26.