how can I break for looping in get json jquery when the condition has reached the right value? I've tried to set variable inside json query code then break it, but it cannot read the variable when the variable is outside of json query code. is there any possible to break that for loop?

here's my scripts.

```
 <?php
  $array = array("test.com","test2.com");
 ?>    

<script type="text/javascript">
var variable, x=0;
var web= <?php echo json_encode($array); ?>;
for(a=0;a<web.length;a++){
    $.getJSON('http://www.'+web[a]+'/checkdomain.php?z=1',function (data) {
        variable = data.showText;
        console.log(variable);
        if(variable=="there is a value here") {
         top.frames['mywebsite'].location.href="http://www."+web[a];
         x= 1;          
        }else {
         x= 0;
        }
    });

    if(x==1){
     break;
    }else {
     continue;
    }

}
</script>

```