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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Civi Contact view errors
Pages: 1 [2]

Author Topic: Civi Contact view errors  (Read 2009 times)

raustin1

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 0
    • University of Notre Dame
  • CiviCRM version: 4.6.11
  • CMS version: Joomla 3.4.8
  • MySQL version: 5.5.45-cll-lve
  • PHP version: 5.6.16
Re: Civi Contact view errors
October 03, 2014, 02:38:10 pm
We'll try that (when my developer bstalcup comes back).

Can't say thank you enough. Hope we find a solution.

bstalcup

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 1
  • CiviCRM version: 4.7.3
  • CMS version: Joomla!
  • MySQL version: 5.5.36-cll-lve
  • PHP version: 5.3.29
Re: Civi Contact view errors
October 06, 2014, 12:51:45 pm
Quote
It might be worth sticking a console.log or other debugging statement into js/crm.ajax.js around line 208

Tried that, and logged the error.  The error was "undefined."  Not the string "undefined" but an actual undefined object.  Any clue?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Civi Contact view errors
October 06, 2014, 12:54:04 pm
Is that just because the .fail() handler currently takes no arguments? Did you add arguments to it?
Try asking your question on the new CiviCRM help site.

bstalcup

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 1
  • CiviCRM version: 4.7.3
  • CMS version: Joomla!
  • MySQL version: 5.5.36-cll-lve
  • PHP version: 5.3.29
Re: Civi Contact view errors
October 06, 2014, 01:28:44 pm
I got it to work, but it's pretty janky, and a kind of hard-coded solution

I replaced the .fail() function which used to be this:

Code: [Select]
}).fail(function(data) {
        that._onFailure(data.responseText);
      });

with this:

Code: [Select]
}).fail(function(data) {
        console.log('begin jankiness');
        console.log(data.responseText);
        console.log(data.responseText.indexOf('{'))
        lol = JSON.parse(data.responseText.slice(data.responseText.indexOf('</script>') + 9 ));
        console.log(lol);
        that.element.html(lol.content);
        //that._onFailure(data.responseText);
      });

So basically it can't handle errors anymore...  ;D

I think what the problem was, is that there was some <script> tag in the data there, and it was causing problems with the JSON parsing, and I just cut the <script> out of the response text in the failure handling.  Is that <script> suppose to be there?  Here's the script I'm talking about:

Code: [Select]
<script type="text/javascript">
cj(document).ready(function() {

if (!window.educationDetails) {

// move the education details from php to javascript
window.educationDetails = [{"university_institute_5":"University of Notre Dame","degree_obtained_8":"B.S.","area_of_study_10":"Computer Science","start_year_18":"2011","end_year_19":"2015"}];

cj('#profilewrap20 #crm-container').append('<u>Education Details:</u><br /><br />');

// loop trough each set of education details
for (var i=0; i<window.educationDetails.length; i++) {

// loop through each field in the set
for (prop in window.educationDetails[i]) {

// prettify the fieldname - strip the last 2 characters from the fieldname, and lose underscores
var label = prop.substring(0, prop.lastIndexOf('_')).replace(/_/g, ' ');

// prepare the html that will be added for this field
var row = '<div id="row-first_name" class="crm-section first_name-section">'
+'<div class="label" style="text-transform: capitalize">'+label+'</div>'
+'<div class="content">'+window.educationDetails[i][prop]+'</div>'
+'<div class="clear"></div>'
+'</div>';

//append it to the page
cj('#profilewrap20 #crm-container').append(row);

}

// put a space between each set of education details
cj('#profilewrap20 #crm-container').append('<br />');

}
}

});
</script>

bstalcup

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 1
  • CiviCRM version: 4.7.3
  • CMS version: Joomla!
  • MySQL version: 5.5.36-cll-lve
  • PHP version: 5.3.29
Re: Civi Contact view errors
October 06, 2014, 01:35:56 pm
I'm pretty sure all that is from an old hook we used to use. We'll take care of it

Thanks for all your help!

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Civi Contact view errors
October 06, 2014, 01:55:47 pm
Yea that javascript is def from custom code on your end (funny that was one of my first suggestions). Looks like you are shoving that script directly into the raw output from php regardless of format (in this case the format is json but you are assuming it's html). That's going to break most of CIviCRM, so I suggest you find a cleaner way to inject it (see CRM_Core_Resources) and then you won't need the janky hack anymore.
Try asking your question on the new CiviCRM help site.

bstalcup

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 1
  • CiviCRM version: 4.7.3
  • CMS version: Joomla!
  • MySQL version: 5.5.36-cll-lve
  • PHP version: 5.3.29
Re: Civi Contact view errors
October 06, 2014, 02:02:19 pm
You'll have to forgive us, it's been about 2 years since we last did anything with that code!   :D

Already working on reducing the jankiness of this solution.  Thanks again.

raustin1

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 0
    • University of Notre Dame
  • CiviCRM version: 4.6.11
  • CMS version: Joomla 3.4.8
  • MySQL version: 5.5.45-cll-lve
  • PHP version: 5.6.16
Re: Civi Contact view errors
October 06, 2014, 07:59:05 pm
I SWEAR I disabled it when testing last week.

Coleman, your help has been invaluable. Thank you.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Civi Contact view errors
October 07, 2014, 08:11:46 am
You're welcome. What did you end up doing to add the script? (or was it obsolete?)
Try asking your question on the new CiviCRM help site.

Jon-man

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • Supporting voluntary action since 1975
  • CiviCRM version: 4.4.6
  • CMS version: Drupal 7.28
  • MySQL version: 5.1.68-cll
  • PHP version: 5.3.18
Re: Civi Contact view errors
February 09, 2015, 03:16:22 am
We had a problem viewing and editing pop-up forms (activities and notes) so by disabling this functionality it works.

The setting is in: -
/civicrm/admin/setting/preferences/display?reset=1
(Enable Pop up Forms - disable this!)

Jon-man

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Civi Contact view errors
February 16, 2015, 12:49:39 pm
Jon-man, that solution is rather drastic, it means you are disabling all pop-up functionality everywhere. This would result in a seriously limited user-interface.
If your site has javascript errors it would be better to find out what they are and fix them. Some common causes are:
  • Incompatible extensions/themes/modules
  • Old tpl overrides or custom code that no longer works with the latest version of CiviCRM
  • PHP notices that display on the screen (on production sites you should configure php to log them to a file instead).
Try asking your question on the new CiviCRM help site.

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Civi Contact view errors

This forum was archived on 2017-11-26.