问题描述
我在加载 AJAX
时遇到问题,我尝试通过 Praveen Kumar
遵循此答案第一个下拉菜单自动更改第二个下拉菜单的选项并从 http://codex.wordpress.org/AJAX_in_Plugins 中了解有关Ajax的信息,并在其中引用
Im having a problem loading the AJAX
and I tried to follow this answer by Praveen Kumar
First drop down menu to auto change the options of a second dropdownand also read about ajax from http://codex.wordpress.org/AJAX_in_Plugins and it is quoted there
所以我想在页面中加载ajax没有问题.我的代码是这样的
So i guess there is no problem loading ajax in my page. My code goes like this
HTML:
<form action="#" method="POST">
<select name="region" onchange="messi_code(this.value)">
<option>Region Select</option>
<option value="East">East</option>
<option value="West">West</option>
<option value="North">North</option>
<option value="South">South</option>
</select>
<br>
<select id="region_branch" name="region_branch">
<option>Select City</option>
</select>
</form>
AJAX:
<script type="text/javascript">
function messi_code(parent){
url= 'process.php?parent=' + parent,
$.get(url,function(data){
alert(data);
/* $("#region_branch").html(data);*/
});
}
</script>
顺便说一句,在ajax脚本中,我尝试了 POST
, GET
并删除了 type
,但在J-控制台,错误提示未捕获的ReferenceError:未定义ajaxfunction:onchange
by the way, in the ajax script I tried POST
, GET
and remove the type
and still having an error in the J-console, error says Uncaught ReferenceError: ajaxfunction is not defined: onchange
在此感谢您的帮助.
推荐答案
<form action="#" method="POST">
<select name="region" onchange="messi_fan(this.value);">
<option>Region Select</option>
<option value="East">East</option>
<option value="West">West</option>
<option value="North">North</option>
<option value="South">South</option>
</select>
<br>
<select id="region_branch" name="region_branch">
<option>Select City</option>
</select>
</form>
<script>
function messi_fan(parent){
url= 'process.php?parent=' + parent;
$.post(url,function(data){
alert(data);
});
}
</script>
这篇关于使用AJAX自动加载第二个下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!