2017-04-21 1 views
0

코드의 'function processResponse (data)'부분에 내 알림이 표시되지 않는 이유를 알아 내려고합니다. 나는 다양한 반환을 시도했다; 옵션은 표시하지만 여전히 거부합니다.성공 알림에 내 알림이 표시되지 않는 이유

누군가 내 실수를 지적하면 고맙겠습니다. 많은 감사합니다.

추신. mysql_escape_string과 같이 게시 된 코드의 보안 문제를 알고 있지만 모든 보안 문제는 사이트가 게시되기 전에 삽입됩니다.

jQuery 코드

<script type="text/javascript"> 

$(function() { 

    $('#srcsubmit').click(function(e) { 
     e.preventDefault(); 
     if ($('#srcBox').val() == '') { 

      notif({ 
       type: "error", 
       msg: "<b>ERROR:<br /><br />You must enter a search term</b><p>Click anywhere to close</p>", 
       height: 99, 
       multiline: true, 
       position: "middle,center", 
       fade: true, 
       timeout: 3000 

      }); 
      return false; 
     } 

     $("#submit").prop("disabled", true); 
     $("#submit2").prop("disabled", true); 
     $("#submit3").prop("disabled", true); 
     var value = $('#srcBox').val(); 
     var dept = '<?php echo $_GET['dept ']; ?>'; 

     var qString = 'sub=' + encodeURIComponent(value) + '&dept=' + encodeURIComponent(dept); 

     $.post('sub_db_handler.php', qString, processResponse); 
    }); 

    function processResponse(data) { 
     if (data === 'true') { 

      alert('That box is not on the system'); <--- this is the problem 
      return; 
     } 

     $('#srcBoxRslt').val(data); 
    }; 
}); 


</script> 

PHP 백엔드

<?php session_start(); ?> 
    <?php 

    $con = mysql_connect("localhost","root",""); 
    if(!$con) { die('Could not connect: ' . mysql_error()); } 
    mysql_select_db("sample", $con); 

    $dept = trim($_POST['dept']); 
    $custref = trim($_POST['sub']); 



    $result = mysql_query("SELECT * FROM boxes WHERE custref = '".$custref."'"); 
    $found = mysql_num_rows($result); 

    if ($found == 0) 
     { 
      echo trim('true'); 

     } else { 

    $query = "SELECT * FROM boxes WHERE department = '".$dept."' AND status = 1 AND custref = '".$custref."'"; 
    $result = mysql_query($query) or die(mysql_error()); 
    $row = mysql_fetch_array($result) or die(mysql_error()); 
    $r = $row['custref']; 

    $str = json_encode($r); 
    echo trim($str, '"'); 

    } 


     ?> 
+1

'데이터가 아닌 별도의 사용을 제거하기 때문에 여분의 공간의 true 동일하지 않습니다 동등한 사실 ' – guradio

+0

개발자 콘솔 열기 및 오류 확인, 원시 출력 참조 –

+0

@guradio 방화 광 탭에서 true를 표시 – user1532468

답변

관련 문제