-3

Don't no why but the javascript code stop functioning when i use the getJSON. nothing happens. Please assist.

function check_order(){
    var mob= $('#order-status-input').val();

    if (/^[0-9]{1,10}$/.test(+mob) && mob.length==10){
        document.getElementById('check_status_conf').style.display="block";
        $.getJSON("status.php", {mobile:mob},function(data){
            if(data['status']==1){
                document.getElementById('check_status_conf').innerHTML=data['message'];
            }
        }
    }
};
#check_status_conf {
    display:none; 
    background:#FFFFFF; 
    width:300px; 
    float:right; 
    z-index:109; 
    position:fixed; 
    margin-left:71%; 
    border-radius:10px;  
    height:auto; 
    min-height:100px; 
    max-height:400px; 
    color:#666666; 
    overflow-y:scroll;
}
<span class="check_status_conf" id="check_status_conf"><br></span>
JAAulde
  • 19,250
  • 5
  • 52
  • 63
user3481078
  • 3
  • 1
  • 4
  • 1
    Please fix your syntax error so that we can at least *try* to execute your code and reproduce your problem. Btw, "stop functioning" is not a very detailed error description… – Bergi Sep 18 '14 at 19:28
  • I think his problem will just go away if he fixes his syntax error. Your parentheses are not balanced. – Barmar Sep 18 '14 at 19:29
  • What have you tried to do to troubleshoot the issue? Have you passed in an error callback, wrapped the whole thing int a try/catch? – BrMcMullin Sep 18 '14 at 19:30
  • 1
    Have you looked in the Javascript console for the complaint about a syntax error? You're missing the close parenthesis for `$.getJSON(`. – Barmar Sep 18 '14 at 19:31
  • Actually i needed a fix as soon as possible. So in a hurry i typed things in this way. the parentheses are blncd in my code. but still no good – user3481078 Sep 18 '14 at 19:48
  • Show us `status.php`. – StackSlave Sep 18 '14 at 19:54

1 Answers1

0

If using jQuery, use it. The test() method takes a String, and you're missing the closing parenthesis on $.getJSON(). If those minor fixes don't do the job, it's probably something to do with status.php.

function check_order(){
  var mob = $('#order-status-input').val(), statConf = $('#check_status_conf');
  if(/^\d{10}$/.test(mob)){
    statConf.css('display', 'block');
    $.getJSON('status.php', {mobile:mob}, function(data){
      if(+data.status === 1){
        statConf.html(data.message);
      }
    });
  }
}
StackSlave
  • 10,613
  • 2
  • 18
  • 35