简体   繁体   English

同一代码在两台服务器上的行为不同

[英]Same code behave differently on two servers

In my localhost and one server is all right, array has the same values within console inside $.each function like outside, but on another server that code behave differently. 在我的本地主机和一台服务器上可以,数组在$ .each函数内部的控制台中的值与外部相同,但在另一台服务器上,代码的行为不同。 Second console return empty array, inside it is correct. 第二个控制台返回空数组,里面是正确的。 How can server change client-side language behaviour? 服务器如何更改客户端语言行为?

var isChecked = [];
$('.x').each(function() {
  if ($(this).prop('checked')) {
    id = $(this).prop('id').split('_')[1];
    isChecked.push(id);
    console.log(isChecked);
  } else {
    isChecked.splice($.inArray(id, isChecked), 1);
  }
});
console.log(isChecked);

Markup is: 标记是:

<table>
  <tr class=header>
    <td class=first>
      <input type="checkbox" id="c">
      <label for="c"><span class="tablecheck"></span></label>
    </td>
    <td class="header" colspan=""><a href="/">User group</a></td>
    <td class="header" colspan=""><a href="/">Firstname</a></td>
    <td class="header" colspan="2"><a href="/">Lastname</a></td>
  </tr>
  <tr class="">
    <td class=first>
      <input type="checkbox" id="x_41" class="x">
      <label for="x_41"><span class="tablecheck"></span></label>
    </td>
    <td>Admin</td>
    <td>Firstname</td>
    <td>Lastname</td>
  </tr>
</table>

How can server change client-side language behaviour? 服务器如何更改客户端语言行为?

I would guess your browser has cached an older version of the JavaScript file from the second server, which would explain why you are seeing different behavior. 我想您的浏览器已从第二台服务器缓存了旧版本的JavaScript文件,这将解释您为什么会看到不同的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM