$filename ="E:\\Serialportread\\boxcheck.txt";
    $handle = fopen($filename, "r");
    $data = fread($handle, filesize($filename));
    fclose($handle);
if($data=="CLOSED")
{
echo'<td><button id="read" class="bott2" style="margin-top:18px;">Read</button></td><td>';
}
else{
echo'<td><button id="read" class="bott2" style="margin-top:18px;" disabled="disabled">Read</button></td><td>';
}

this happening before click.

在点击之前发生这种情况。

code below is on click function defined :

以下代码定义了点击功能:

$('#read').click(function(e){
    var fso1, ForReading;
    ForReading = 1;var status;
    fso1 = new ActiveXObject("Scripting.FileSystemObject");
    file = fso1.OpenTextFile("E:\\Serialportread\\boxcheck.txt", ForReading, false, -2);
    status = file.ReadLine();
    file.Close();
    alert(status);
    if(status=='CLOSED')
    {
      alert('ysess');
      $.fn.a();
      e.preventDefault();
      }
      else{
      alert('error')
    $('#read').html('');
      str='<diasabled="disabled">';
      $('#read').append(str);
    alert('yes');


      }
    });

Both the codes are not working. I tried another code as well but that was refreshing my page again and again which i don't want .

这两个代码都不起作用。我也尝试了另一个代码,但这一次又一次刷新我的页面,我不想要。

1 个解决方案

#1


0

There is a syntax error in

语法错误

str='<diasabled="disabled">';

diAsabled

You should better try not to mess with the HTML - use style instead:

你最好尽量不要乱用HTML - 使用样式:

if(status=='CLOSED')
{
  alert('ysess');
  var cb = $("#read");
  cb.removeAttribute("disabled");
  removeClass(cb, "button-disabled"); 
}
else
{
  alert('error')
  var cb = $('#read');
  // visually change the button - otherwise it does not look as disabled
  addClass(cb, "button-disabled"); 
  cb.setAttribute("disabled","");
  alert('yes');
}

更多相关文章

  1. php mail函数一段好的代码
  2. 用于上传多个文件的PHP代码
  3. (phpQuery)对网站产品信息采集代码的优化
  4. 韩顺平_php从入门到精通_视频教程_学习笔记_源代码图解_PPT文档
  5. 【MySQL 技巧分享】 mysql -e 加 v 简化代码
  6. Oracle相当于MySQL代码“插入虚拟”以返回错误消息
  7. 登录使用PHP并´t显示任何html代码
  8. 在代码点火器中从mysql迁移到postgresql
  9. 【动软.Net代码生成器】连接MySQL生成C#的POCO实体类(Model)

随机推荐

  1. Android学习路线图
  2. android 各种小项目
  3. Android流式布局FlowLayout
  4. Android: Android图形基础
  5. Android学习笔记 - 控件篇
  6. 做Android的感想
  7. Android API中文文档AccessibilityServic
  8. EditText部分属性使用
  9. Android标题栏、状态栏、全屏
  10. Android向服务器的数据库MySQL传输数据:经