jQuery不能在一台PC上工作而在另一台PC上工作

时间:2013-04-17 12:16:31

标签: jquery

我有以下jQuery + PHP代码可以在一台PC上运行,但不能在另一台PC上运行。

非工作:

<head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script type="text/javascript" src="javascripts/hrscripts/sortable.js"></script>
  <link href="/css/select2.css" rel="stylesheet"/>
  <script src="/javascripts/select2.js"></script>
  <script>
    $(document).ready(function() {
      $("#select_employee").select2();
    });
  </script>
</head>

<?php
  $allemp=$this->AllEmployees;
  echo "<form method='post' action='' id='employeesselection'>";
  echo "<select name='select_employee' id='select_employee'>";
  echo "<option value=''>Select an employee...</option>";

  foreach($allemp as $row) {
    $selected = ($row['Id'] == $_POST['select_employee'])?'selected="selected"':'';
    echo '<option '.$selected.' value="'.$row['Id'].'">'.$row['Etunimi'].' - '. $row['Sukunimi'].'</option>';
  }
  echo "</select>";

工作:

<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
  <link href="css/select2.css" rel="stylesheet"/>
  <script src="select2.js"></script>
  <script>
    $(document).ready(function() {
      $("#select_employee").select2();
    });
  </script>
</head>

<?php
  include "db.php";
  $employees=mysql_query("SELECT * FROM asiakas");

  echo "<form method='post' action='' id='employeesselection'><select name='select_employee' id='select_employee'>";

  while($row=mysql_fetch_array($employees)) {
    $selected = ($row['Id'] == $_POST['select_employee'])?'selected="selected"':'';
    echo '<option '.$selected.' value="'.$row['Id'].'">'.$row['Etunimi'].' - '. $row['Sukunimi'].'</option>';
  }
  echo "</select>

这几乎是相同的代码。我无法弄清楚我做错了什么。

2 个答案:

答案 0 :(得分:0)

缺少http://:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

答案 1 :(得分:0)

在同一浏览器上检查两个结果,并确保已加载所有页面脚本, 您可以通过“f12 - &gt;资源 - &gt;脚本”

在Chrome上执行此操作