• Resolved edinmusic

    (@edinmusic)


    Hi,

    after I’ve updated my site to WP 3.9 this error appeared:

    Uncaught TypeError: Cannot read property ‘indexOf’ of null alfie.weather.js?ver=3.9:162

    ...
    var obj = $.map( results, function ( result, i ) {
          // Day or night?
          wpd = result.item.pubDate;
          n = wpd.indexOf( ":" );
          tpb = me.getTimeAsDate( wpd.substr( n - 2, 8 ) );
          tsr = me.getTimeAsDate( result.astronomy.sunrise );
          tss = me.getTimeAsDate( result.astronomy.sunset );
    ...

    Can you please help me resolve it?

    https://wordpress.org/plugins/alfie-wp-weather/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author appcuarium

    (@appcuarium)

    Hi,

    Thanks for your input. This issue has been resolved. Please update the plugin to version 1.2.0.

    Kind regards.
    The Alfie Team

    Thread Starter edinmusic

    (@edinmusic)

    Hi,

    Thanks for your answer. But now there’s new issue at alfie.weather.min.js?ver=3.9:22. Same “Cannot read property ‘indexOf’ of null” error.

    Thanks in advance 😉

    Plugin Author appcuarium

    (@appcuarium)

    Hi,

    Where do you see this error, on site or on admin?

    Thanks.

    Thread Starter edinmusic

    (@edinmusic)

    On site. This is the site: http://velikakladusa.gov.ba/
    The Weather widget should be under “Vrijeme” title in the right sidebar.

    Plugin Author appcuarium

    (@appcuarium)

    Hi,

    This is a documented issue, please make sure your server has allow_url_fopen enabled.

    More on this here -> http://wordpress.org/support/topic/widget-only-displaying-title?replies=10

    Hope this helps.

    Best regards.
    The Alfie Team

    Thread Starter edinmusic

    (@edinmusic)

    I’ve replaced part of your getfeed.php file, and now it’s ok. The problem was with allow_url_fopen. I’ve replaced file_get_contents with curl and now it’s ok. Here’s the code:

    // Get the JSON encoded response from Yahoo! API. (added cURL)
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) user/2010 Firefox/1.0");
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $json = curl_exec($ch);
    curl_close($ch);
    
    error_log($json);
    
    //$json = file_get_contents( $api, 0, null, null ); // This is the old line
    
    // Decode the response so we can translate the condition codes and week days
    $decoded = json_decode( $json );
    Plugin Author appcuarium

    (@appcuarium)

    Hi,

    That will be a temporary fix, which will be overwritten if you update the plugi-in. We’ll probably add a “plan B” solution involving cURL, in case allow_url_fopen is not enabled, but still, there are less chances for cURL to be installed on a budget server than allow_url_fopen enabled.

    We will try to implement this in the next version.

    Best regards.
    The Alfie Team

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘JS error at alfie.weather.js?ver=3.9:162’ is closed to new replies.