【问题标题】:Page is not loading on selected dropdown页面未加载到选定的下拉列表中
【发布时间】:2020-07-29 08:34:49
【问题描述】:

当我上传到 File Zilla 时,我收到了这条消息 - Failed to load resource: the server responded with a status of 404 (Not Found) https://england-cities.html

当我在第一个选择菜单中选择一个国家时,它应该允许用户在另一个选择菜单中选择城市。

当我实时使用 Visual Studio Code 时,代码运行良好。但是当我出于某种原因上传到 File Zilla 时无法正常工作。

正如您在代码中看到的那样,我要求加载每个 Html 内部的数据列表,然后我使用回调函数连接到 Ajax 天气 API。

为什么会这样?

感谢您的帮助。

$(document).ready(function () {
    $('#country').change(function () {
        $('#counties').load($(this).val() + '-cities' + '.html');
        $('#counties').change(function () {
            let stateSelected = $(this).val();
            getTheWeatherData(stateSelected);
        });
    });
});

【问题讨论】:

标签: javascript jquery html drop-down-menu http-status-code-404


【解决方案1】:

尝试在load()之后添加'https://www.yoururl/'

$(document).ready(function () {
    $('#country').change(function () {
        $('#counties').load('https://www.yoururl/'+$(this).val() + '-cities' + '.html');
        $('#counties').change(function () {
            let stateSelected = $(this).val();
            getTheWeatherData(stateSelected);
        });
    });
});

【讨论】:

  • 也没有用。这个函数是加载五个包含数据的 HTML 页面。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-03-19
  • 2015-03-25
  • 1970-01-01
  • 2019-04-09
  • 2017-05-18
  • 1970-01-01
  • 2013-01-20
相关资源
最近更新 更多