2015-11-18 17:18
浏览 13

Jquery检查是否有东西在PHP中发布了$ _POST

I haven't been able to find an answer to this that works. All I want to do is check with Jquery to see if something has been posted in PHP.


if ($_POST['clockin'] == "Clock In") {  
    //some code

And for the Jquery:

if (<?php $_POST['clockin'] == "Clock In" ?>) {
            $(this).attr('disabled', 'disabled');

图片转代码服务由CSDN问答提供 功能建议

我无法找到有效的答案。 我想做的就是检查Jquery,看看是否已经在PHP中发布了一些内容。


  if($ _POST ['clockin'] ==“Clock In”){


  if(&lt;?php $ _POST ['  clockin'] ==“Clock In”?&gt;){
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dtmsaqtly798322992 2015-11-18 17:20

    Try this,

    <?php if ( isset($_POST['clockin'])) { 
        if ( $_POST['clockin'] == "Clock In") { ?>
                $(this).attr('disabled', 'disabled');
    <?php } } ?>

    Make sure you enclose script with <script></script> tags.

    打赏 评论
  • douxin20081125 2015-11-18 17:56

    You shouldn't mix Server and Client Code(JS) unless you have no option but you can embed php in html thats advantage of scripting If you want to check it on Page load if previous page was form submission

    Use Flag to check whether clock in is set php

       if ($_POST['clockin'] == "Clock In") {  


           <form onsubmit="return changeAttr(<?php echo $flag ?>);"> 
               <input type="submit" id="clockin" />
               <input id="clockout" />


    function changeAttr(flag) {
      var clckin = document.getElementById('clockin');
      var clckout = document.getElementById('clockout');
      if (flag) {
        clckin.disabled = true;
        clckout.disabled = false;
        return false;
      return true;
    打赏 评论

相关推荐 更多相似问题