How to debug and find error code with json and ajax


How to debug json code. How to used console.log function.output return null value for other file used json ajax debug. How to check and debug the error, output for next file using ajax and json. how to debug data for using json and ajax in php


How to used and debug getJSON with console.log() and alert function to output json structure 

console output show in the browser 

console.log( ); used to check the out for next file 

for example



console output show and check in firebug console option 

press F12 and bottom side show option console

and 2nd option used to alert() function 

for example 







  $("#batchselect").click(function() { 

       var htmcont;

  var txt = $("#batchselect").val();            


$.getJSON('followupaddsearch.php',{'batchselect':txt}, function(data) {


htmcont = "";

var id =; 

var sub = data.sub; 



htmcont += '<div style="width:400px;" >';

htmcont += '<input class="form-control boxed" id="inputaddname1" name="" value="'+sub+'" type="text">';

htmcont += '</div>';






<div style="width:200px; float:left">

         <select class="form-control" id="batchselect" >


$showst=mysql_query("Select * from batch");


<option value="<?php echo $rowlinkst['id']; ?>,<?php echo $rowlinkst['batchcode']; ?>"><?php echo $rowlinkst['batchname']; ?></option>

<?php } ?>



<div style="width:200px; float:left" id="resultbatchselect">

<input type="text" class="form-control boxed" id="inputaddname1" name="" value="">










$batchselect =  $_GET['batchselect']; 


//echo $batchselect;


$batchselectidc = explode(",", $batchselect);

    $batchselectid = $batchselectidc[0];

$batchselectname = $batchselectidc[1];




$showst=mysql_query("SELECT * FROM subject where batchcodeid = '".$batchselectid."'");



$data = array();

   $data = array(    

   'id' => $rowlinkst['id'],   

   'sub' => $rowlinkst['sub']   


 //$data =   $batchselect 

  // $data = "SELECT * FROM subject where batchcodeid = '".$batchselectid."' order by id desc limit 1";

 echo json_encode($data);