简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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