Ajax Used Basic 3 onclick show detail fetch data same action file use getJSON

ajax 0 Comments

Ajax Used Basic 3 onclick show detail fetch data same action file use getJSON how to fetch value another file in same action file in input box using ajax php

html code onclick

<button type="button" id="seahaddfollow" name="submitseach" class="btn btn-success" style="float:right;">Search</button>

 

Html Form same create in ajax with html php design

 

		 <form role="form" action="" method="POST">	
			    <div id='followupaddeditshow'>
			    <div class="form-group">
				<label class="control-label" for="inputSuccess1">Phone : &nbsp </label> 
				<label class="control-label" for="inputSuccess1" style="width:80%"> <input type="text" class="form-control boxed" id="inputaddpho1" name="" value="<?php echo $_POST['phonecode']; ?>" readonly style="background-color:#EBEBE4">  </label>								
								</div>
								<div class="form-group ">
								<label class="control-label" for="inputSuccess1"> Name : &nbsp </label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> <input type="text" class="form-control boxed" id="inputaddname1" name="" value="<?php echo $rowlinkadd['name']; ?>"> </label>
								</div>
								<div class="form-group ">
								<label class="control-label" for="inputSuccess1">Quali. : &nbsp</label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> <input type="text" class="form-control boxed" id="inputquali1" value="<?php echo $rowlinkadd['quali']; ?>"> 						
								</label>
								</div>
								<div class="form-group ">
								<label class="control-label" for="inputSuccess1">Course  : </label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> <input type="text" class="form-control boxed" id="inputcourese1" value="<?php echo $rowlinkadd['courses']; ?>">   </label>
								</div>
								<div class="form-group ">
								<label class="control-label" for="inputSuccess1">City : &nbsp&nbsp&nbsp&nbsp</label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> <input type="text" class="form-control boxed" id="inputaddcity1" value="<?php echo $rowlinkadd['city']; ?>"> 						
								<?php $datetime =  date("Y-m-d"); ?>
								<input type="hidden" class="form-control boxed" id="dateaddinput1" value="<?php echo $datetime; ?>"> 
								 </label>
								</div>
								
								
								<div class="form-group ">
								<label class="control-label" for="inputSuccess1">  </label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> <input type="hidden" class="form-control boxed" id="statusalluponrp" value="<?php echo $rowlinkadd['statusall']; ?>">    </label>
								</div>
								
					</div> 		
					
					   <div class="form-group ">
								<label class="control-label" for="inputSuccess1">Status : </label>
								<label class="control-label" for="inputSuccess1" style="width:82%"> 
								<select class="form-control" id="stataddupinnew">
				               <option value="1">Student</option>
				               <option value="2">Parents</option>
				               </select>		
								 </label>
								  <!--<label class="control-label" for="inputSuccess1" style="width:85%"> <input type="hidden" class="form-control boxed" id="statusalluponrp" value="<?php //echo $rowlinkadd['statusall']; ?>"> -->
								</div>	
								
								<!--<div class="col-lg-6" style="color:#000000; padding:4px; font-size:14px; text-align:center; background-color:#f5f5f5">
				<input type="button" value="Add Detail" name="subnewadd" id="subnewadd" class = "btn btn-success" style="width:50%; height:40px; text-align:center"/>
				 </div>-->
				 <div class="col-lg-12" style="color:#000000; padding:4px; font-size:14px; text-align:center; background-color:#f5f5f5">
				 <input type="button" value="Update Detail" name="editphsubnewadd" id="editphsubnewadd" class = "btn btn-primary" style="width:35%; height:40px; text-align:center"/>
				 </div>
				 </form>

 

 

 

aajax code

 

 

<script>  
 $(document).ready(function(){ 
 
  $("#seahaddfollow").click(function() { 
  var htmcont;
  		var txt = $("#country_name").val();
		//alert(txt);
		
		$.getJSON('followupaddeditshow.php',{'phonecode':txt}, function(data) {	
		//alert(data);	
		htmcont = "";	
		        var name = data.name; 
				var mbl = data.mbl;
				var quali = data.quali;
				var courses = data.courses; 
				var city = data.city;
				var statusall = data.statusall;
				
				/*htmcont += "<div>";
				htmcont += "<lable>Name</lable><input class='name' id='name' name='name' value='"+name+"'>"
				htmcont += "</div>"*/
				
				
				htmcont += '<div class="form-group">';
				htmcont += '<label class="control-label" for="inputSuccess1">Phone : &nbsp; </label>'; 
				htmcont += '<label class="control-label" for="inputSuccess1" style="width:80%"> <input class="form-control boxed" id="inputaddpho1" name="" value="'+mbl+'" readonly style="background-color:#EBEBE4" type="text">  </label>';								
				htmcont += '</div>';
				
				htmcont += '<div class="form-group">';
				htmcont += '<label class="control-label" for="inputSuccess1">Name : &nbsp; </label>' 
				htmcont += '<label class="control-label" for="inputSuccess1" style="width:80%"> <input class="form-control boxed" id="inputaddname1" name="" value="'+name+'" type="text">  </label>'								
				htmcont += '</div>'
				
				htmcont += '<div class="form-group">';
				htmcont += '<label class="control-label" for="inputSuccess1">Quali. : &nbsp;</label>'
				htmcont += '<label class="control-label" for="inputSuccess1" style="width:82%"> <input class="form-control boxed" id="inputquali1" value="'+quali+'" type="text">' 						
				htmcont += '</div>'
				
			    htmcont +=  '<div class="form-group ">';
				htmcont += 	'<label class="control-label" for="inputSuccess1">Course  : </label>'
				htmcont += 	'<label class="control-label" for="inputSuccess1" style="width:82%"> <input class="form-control boxed" id="inputcourese1" value="'+courses+'" type="text">  </label>'
				htmcont += 	'</div>'
				
				htmcont +=  '<div class="form-group ">';
				htmcont += 	'<label class="control-label" for="inputSuccess1">City : &nbsp;&nbsp;&nbsp;&nbsp;</label>'
				htmcont += 	'<label class="control-label" for="inputSuccess1" style="width:82%"> <input class="form-control boxed" id="inputaddcity1" value="'+city+'" type="text">' 						
				htmcont += 	'</div>'
				
				htmcont +=  '<div class="form-group ">';
				htmcont += 	'<label class="control-label" for="inputSuccess1"> &nbsp;&nbsp;&nbsp;&nbsp;</label>'
				htmcont += 	'<label class="control-label" for="inputSuccess1" style="width:82%"> <input class="form-control boxed" id="statusalluponrp" type="hidden" value="'+statusall+'" type="text">' 						
				htmcont += 	'</div>'
				
				htmcont += '<input type="hidden" class="form-control boxed" id="phonenocomment" name="phonenoclist" value="'+mbl+'" style="font-weight:normal" readonly>'
				
				/*htmcont += "<div>";
				htmcont += "<lable>mbl</lable><input class='mbl' id='mbl' name='mbl' value='"+mbl+"'>"
				htmcont += "</div>"*/
				
				
				$("#followupaddeditshow").html(htmcont);
				
				
				
				$("#followupaddeditshow").html(htmcont);					
				htmcontname = "";	
		        var name = data.name; 
				htmcontname += '<div class="form-group">';
				htmcontname += '<label class="control-label" for="inputSuccess1" style="width:95%"> '+name+' </label>'								
				htmcontname += '</div>'					
				$("#followshowname").html(htmcontname);	
						
		
		     });
		
		 });
 });  
 </script>

fetch data value to another file

 

<?php
include('config.php');
include("sessionset.php"); 	
		
	?>		
 <?php  $phonse = $_GET['phonecode'];
						
		$check = mysql_query("SELECT * FROM mobile WHERE mbl = '$phonse' AND mbl IS NOT NULL order by id desc");
		$checkno = mysql_num_rows($check);
		$rowlinkadd=mysql_fetch_array($check);	  
					  
	  
	   $data = array();
	    $data = array(  
   'mbl' => $rowlinkadd['mbl'],
   'name' => $rowlinkadd['name'], 
   'courses' => $rowlinkadd['courses'],
    'city' => $rowlinkadd['city'],
	'quali' => $rowlinkadd['quali'],
	'statusall' => $rowlinkadd['statusall']
   );
 

 echo json_encode($data);
	  
		
		 
		  ?>