J
J
John Freeman2015-02-25 19:49:21
JavaScript
John Freeman, 2015-02-25 19:49:21

Chrome extension, why is the javascript code not working?

I can't understand why the javascript code in the chrome extension does not work! Another javascript code works well (code for date/time)

javascript code (jQuery):

(function ($) {
    $.get("http://ipinfo.io", function (response) {
    $("#ip").html("IP: " + response.ip);
    $("#weather-city").html(response.city);
    $(document).ready(function() {
    $('#weather_city').val(response.city),
    $('#units_metric').val('metric');
    processForm();
  });
}, "jsonp");
    
  /**
   * Callback to process the form.
   */
  function processForm() {
    // Fetch the data from the public API through JSONP.
    // See http://openweathermap.org/API
    $.ajax({
      url: 'http://api.openweathermap.org/data/2.5/weather',
      jsonp: 'callback',
      dataType: 'jsonp',
      cache: false,
      data: {
        q: $('#weather_city').val(),
        units: 'metric'
      },
      // work with the response
      success: function (response) {
        $('#weather_description').text(response.weather[0].description);
        $('#weather-temprature').text(response.main.temp);
        
      },
    });
  }
})(jQuery);


I wrote the code both in and simply connected from another file <head></head>
<script type='text/javascript' src='assets/js/weather.js'></script>


Nothing helps!
on the page itself I write:

<div class='header-weather'>
        <div id="weather-city"></div>
                                <span id="weather-temprature"></span> °C
                                       <form id="weather_status_form">
                                       <input type="hidden" id="weather_city" name="city" />
                                       </form>
</div>


on the page just through the address bar, everything works fine!
But already in chrome itself it does not show everything that it should!
Example on the page: test.anyout.ru/2 (NOT advertising)
Please help!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
stepandra94, 2015-02-25
@stepandra94

Check for all files in manifest.json

M
mayorovp, 2015-02-25
@mayorovp

How do you add this code to the extension? And where?
content script, just a page in an extension, something popup?
What's in the console?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question