简体   繁体   English

Ajax更改下拉菜单不会保持不变

[英]Ajax changes drop down menu doesn't remain the same

I have a small issue on a search form. 我在搜索表单上有一个小问题。 PLease check this: http://www.fortisfitness.ca/test/script.php 请检查以下内容: http : //www.fortisfitness.ca/test/script.php

What's the problem? 有什么问题? When I select the country, the "cities" drop down refreshes with the specific values for that country. 当我选择国家/地区时,“城市”下拉列表将使用该国家/地区的特定值刷新。 All good, but when I select a city, the data is loaded corectly from the database, but the city value from the dropdown menu remains at "All" value. 一切都很好,但是当我选择一个城市时,数据会从数据库中完全加载,但是下拉菜单中的城市值仍为“全部”值。

I use two ajax functions. 我使用两个ajax函数。 One for loading data into the table and one for refreshing the dropdown list. 一种用于将数据加载到表中,另一种用于刷新下拉列表。 Please help . 请帮忙 。 . . Thank you! 谢谢!

its not about your JavaScript code, its somewhere on the server site. 它与您的JavaScript代码无关,而是在服务器站点上的某个地方。

the request of the ajax call, when selecting a city, is like this: 选择城市时,ajax调用的请求如下所示:

get_city.php?S_City=&D_Country=&D_City=%20Sao%20Miguel%A0&S_Site=&priceh=&time=&pag=1

the response is: 响应是:

<option SELECTED value="">All</option><option value=""></option><option value=" Äkkilähtö"> Äkkilähtö</option>
...

in your ajax complete function you set the html code of the dropdown with the response: 在您的ajax complete函数中,使用响应设置下拉列表的html代码:

$("#titles1").html(msg);

as you can see, the response returns the dropdown box with the "all" option selected. 如您所见,响应将返回一个下拉框,其中选中了“所有”选项。 so, take a closer look at your php code! 因此,请仔细查看您的php代码!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM