0

I have a pretty JavaScript-heavy site that I'm working on, so to try and keep the code a little more under control, I tried to group my code into several logical external JavaScript files (.js files). For the most part it works just fine, but for some reason one function located in the file viewer.js file does not like being called from the ajax.js file (in other words, it's not - the Firebug console tells me nb_displayError is not defined (where the function in question is nb_displayError().

I tried placing the viewer.js script tag both above and below my ajax.js script tag in my HTML file, but neither seemed to make a difference. Strangely, I can call functions in my ajax.js file from another JavaScript file but this one in particular fails. Any thoughts as to why?

In case it's useful to you, the function calling creating this issue is defined as the following (I don't think it's anything particularly tricky):

function populateZoomLevel() {
    var model = $('#modtype').children(':selected').text();
    var lat = $("#loc-label").data('location').latitude;
    var lon = $("#loc-label").data('location').longitude;

    $.get("checkDomains.php", { result: 'zoomlevel', lat: lat, lon: lon, model: model })
        .done(function(responseText){
            if(responseText.substring(0, 7) == "error: "){  // Error flag
                nb_displayError(responseText);
                return;                          // Don't do anything further
            }

            $('#zoomlevel').html(responseText);
        });
}
4

0 回答 0