阿贾克斯:加载网页内容div内选择框加载、网页、内容、阿贾克斯

2023-09-10 18:01:02 作者:起个破也忒费劲了

我试图加载页面内容为通过Ajax一个div当选择了选择选项

I'm trying to load page content into a div via Ajax when a select option is selected

如。我有一个选择框有2个选项的值的test.html和test1.HTML下,我有一个div,并想从test.html中和test1.HTML内容的选择框发生变化时,分区加载...通过Ajax 有什么建议?

eg. I have a select box with 2 options the values are test.HTML and test1.HTML and under that I have a div and want the content from test.HTML and test1.HTML to load in the div when the select box changes... Via Ajax any suggestions?

感谢

推荐答案

当然,这可以是很简单的:

Sure, that can be rather simple:

$("#mySelect").change(function(){
  $("#myDiv").load( $(this).val() );
});

<select id="mySelect">
  <option>test.html</option>
  <option>test1.html</option>
</select>

<div id="myDiv"></div>