对变化中选择加载使用jQuery负荷另一个选择选项负荷、选项、加载、jQuery

2023-09-11 01:34:56 作者:肥崽

下面是我的Javascript,低于与course_name的ID和日期

的ID一个div一个选择框

 <脚本>
$('#course_name')。改变(函数(){
    URL =date_range.php courseID =$('#course_name)VAL()。
  $(#日期)。载荷(URL)
});

< / SCRIPT>
 

当我打电话date_range.php?courseID = 1,通过我的浏览器,它显示的日期,但code以上没有加载。

解决方案

  URL =date_range.php courseID =?+ $('#course_name)VAL()。
 
怎样更改电脑启动时一键还原处的等待时间

或者更好的是,

  URL =date_range.php courseID =?+ parseInt函数($('#course_name)VAL());
 

第二个将始终返回一个号码,这样它的0(零)或以上,如果#course_name值是一个非数字编号,将返回零,否则返回数...当你想这是非常有用的验证服务器上的值。

Here is my Javascript which is below a select box with the id of "course_name" and a div with an id of "dates"

<script>
$('#course_name').change(function() {
    url = "date_range.php?courseID=".$('#course_name').val();
  $("#dates").load(url)
});

</script>

when i call date_range.php?courseID=1 through my browser it displays the dates but the code above is not loading.

解决方案

url = "date_range.php?courseID="+$('#course_name').val();

or better still,

url = "date_range.php?courseID="+parseInt($('#course_name').val());

the second one will always return a number so it's either 0 (zero) or above, if the #course_name value is a non numeric number it would return zero, otherwise returns the number... this is especially useful when you want to validate the value on the server.