一个脚本运行正常,两个脚本都没有运行

时间:2017-06-04 06:37:26

标签: javascript php jquery ajax

如果我运行以下脚本之一然后运行正常,但如果我同时运行两个     的     脚本然后只运行最后一个脚本。但我想运行这两个脚本,然后如何解决,我的脚本代码在下面

<!-- JS -->
<link rel="stylesheet" href="date style/date.css">
<script src="date style/1.js"></script>
<script src="date style/2.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
<script>
$( function() {
$( "#datepicker1" ).datepicker();
} );
</script>
<script 
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$( document ).ready(function() {});
function my_validate_func() {
var name = $('#name').val();
var year = $('#year').val();
var course = $('#course').val();
var branch_name = $('#branch_name').val();
if ($('#name').val() != "" && $('#year').val() != "" &&
$('#course').val() != "" && $('#branch_name').val() != "") {
$.ajax({
type: "POST",
url: 'roll.php',
data: { name: name, year: year, branch_name: branch_name, 
course: course },
success: function(response) {
$('#roll').val(response);
}
});
}
}
</script>

1 个答案:

答案 0 :(得分:0)

以下是添加JQuery并运行两个脚本的方法:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="date style/1.js"></script>
<script src="date style/2.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    $("#datepicker, #datepicker1").datepicker();
  });

  function my_validate_func() {
    var name = $('#name').val();
    var year = $('#year').val();
    var course = $('#course').val();
    var branch_name = $('#branch_name').val();
    if ($('#name').val() != "" && $('#year').val() != "" &&
      $('#course').val() != "" && $('#branch_name').val() != "") {
      $.ajax({
        type: "POST",
        url: 'roll.php',
        data: {
          name: name,
          year: year,
          branch_name: branch_name,
          course: course
        },
        success: function(response) {
          $('#roll').val(response);
        }
      });
    }
  }
</script>