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 CiviContribute (Moderator: Donald Lobo) »
  • State List disappears when Country chosen on dropdown
Pages: [1]

Author Topic: State List disappears when Country chosen on dropdown  (Read 1851 times)

leahb

  • Guest
State List disappears when Country chosen on dropdown
July 12, 2009, 07:27:29 pm
On the frontend of our site, where contribution pages and event registration pages are.  When 'United States' is chosen from the drop down list, the entire list of states goes blank so no state can be chosen (on the billing information section)

I have checked the localization and everything seems fine there.  I have recently upgraded to 2.2.7 and this is the first glitch I have found.

Does anyone know what I am missing?  The site is www.ncheroes.org
By accessing either the events register page or the Donate page, you will come across the error.

Thank you so much!


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: State List disappears when Country chosen on dropdown
July 12, 2009, 08:06:17 pm

if you goto this url:

https://www.ncheroes.org/index.php?option=com_civicrm&task=civicrm/ajax/jqState&&_id=country_id-5&_name=country_id-5&_value=1228

and do a view source, you will see at the end:


Code: [Select]
<script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"\
));</script><script src="tt_files/ga.js" type="text/javascript"></script>
<script type="text/javascript">
        try {
                var pageTracker = _gat._getTracker("UA-7581046-1");
                pageTracker._trackPageview();
        } catch(err) {}</script>

seems like this is being added by another joomla component/plugin (for google analytics) which messes up the json object

you can compare the output you get with the one we get on the demo machine:

http://drupal.demo.civicrm.org/civicrm/ajax/jqState?_id=country_id-5&_name=country_id-5&_value=1228

not that u'll need to do a view source to spot the differences

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

leahb

  • Guest
Re: State List disappears when Country chosen on dropdown
July 12, 2009, 08:14:21 pm
Ah ha - wonderful.

I disabled the plugin and everything is back in top shape.

I guess there is no way to run this plugin with CiviCRM huh?  Any suggestions for a friendly google tracker?

Thanks so much Lobo!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: State List disappears when Country chosen on dropdown
July 12, 2009, 08:19:00 pm

for ajax queries we do an explicit exit from within civicrm code, so the tracker should not be adding that code.

sorry limited joomla experience, so dont know a lot about other modules/plugins

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: State List disappears when Country chosen on dropdown
July 13, 2009, 03:58:43 pm
I'm troubleshooting a similar problem. I have pretty much removed any potential conflict-creating extensions, and the problem remains. What's weird is when I try to access the url to view the ajax query results, I get nothing. Empty page. Any ideas?
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: State List disappears when Country chosen on dropdown
July 13, 2009, 04:17:00 pm

1. what does firebug tell u

2. is your url of the same format as the ones mentioned in this topic

ping me on skype/IRC and we can take a look

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: State List disappears when Country chosen on dropdown
July 14, 2009, 05:20:09 am
The problem with my install seems to be with JSON. The json_encode function simply isn't working -- it doesn't convert the array into that format. Any more ideas?
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: State List disappears when Country chosen on dropdown
July 14, 2009, 07:11:54 am

what version of php?

u might want to write a small php script and see what json_encode returns for various parameter values

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: State List disappears when Country chosen on dropdown
July 14, 2009, 07:37:05 am
I was afraid you'd ask that. PHP 5.1.6.

I know that JSON was added to PHP 5.2. But it looks like you actually construct the JSON array manually in json_encode -- i.e. you're not using any existing libraries or builtin functions.

When I add debug statements to print the array, it displays fine. But I added echo statements to JSON.php encode function, right at the beginning, and they're never hit. It just dies when it gets to json_encode ($elements) (in CRM/Core/Page/AJAX/Location.php).

support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: State List disappears when Country chosen on dropdown
July 14, 2009, 08:27:53 am
Well, problem was indeed that I'm running on 5.1.6 and json_encode is a native 5.2 function. I was able to create something of a workaround.

In CRM/Utils/JSON.php I've added the following function:

Code: [Select]
//modified version of function to be consistent with json_encode in php 5.2
    static function encodejson ( $params, $identifier = 'id' )
    {
        $buildObject = array( );
        foreach ( $params as $value ) {
            $name = addslashes( $value['name'] );
            $id = $value['value'];
            $buildObject[] = "{\"name\":\"$name\",\"value\":$id}";
        }
        $jsonObject = '[' . implode( ',', $buildObject) . ']';
        return $jsonObject;
    }

In CRM/Core/Page/AJAX/Location.php I've modified code so that it calls this new function instead of json_encode:

Code: [Select]
//echo json_encode( $elements );
echo CRM_Utils_JSON::encodejson( $elements );

There's about a dozen instances of json_encode used throughout Civi (including another instance in the Location.php file, I believe). So they would all need to be modified to reference the new function.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • State List disappears when Country chosen on dropdown

This forum was archived on 2017-11-26.