ajax in php/codeigniter
AJAX is a developer's dream, because you can Update a web page without reloading the page Request data from the server - after the page is loaded Receive data from server - after page is loaded send data to server
Sends an
asynchronous http POST request to load data from the server. Its general form
is:
jQuery.post( url [, data ] [, success ] [, dataType ] )
url : is the
only mandatory parameter. This string contains the adress to which to send the
request. The returned data will be ignored if no other parameter is specified
data : A
plain object or string that is sent to the server with the request.
success : A
callback function that is executed if the request succeeds.it takes as an
argument the returned data. It is also passed the text status of the response.
dataType :
The type of data expected from the server. The default is Intelligent Guess
(xml, json, script, text, html). if this parameter is provided, then the
success callback must be provided as well.
Our Best Popular Projects & Posts
Post | Link |
---|---|
School Management System With Full Source Code In php | click here |
ecommerce project in php | click here |
simple login and registration form in php | click here |
Synopsis for online rooms booking project based on PHP | click here |
add multiple images in codeigniter | click here |
beginners project in php with source code | click here |
dynamic country state dropdown in codeigniter | click here |
how to generate pdf using dompdf in codeigniter | click here |
add 1 day to current date in php | click here |
how to check website/blog responsive or not? | click here |
employee attendance management system project in php with source code | click here |
Select one checkbox and disable others | click here |
printing div content with css applied | click here |
best restaurants management system in php | click here |
Preview an image before it is uploaded using jquery | click here |
text editor in jquery | click here |
data table with export button in html | click here |
add multiple images in codeigniter | click here |
codeigniter some steps to install on Your server | click here |
ajax in php/codeigniter | click here |
Create Simple API CRUD with PHP and MySQL | click here |
How to integrate bootstrap theme in codeigniter | click here |
how to prepare for interview | click here |
Convert a date format in PHP | click here |
how to export html table to excel in jquery | click here |
how to create duplicate google peg using ajax | click here |
how to make dropdown searchable in html using jquery | click here |
how to find retirement date in php | click here |
online food order system in php with source code | click here |
school management project admin panel in php | click here |
download link (coppy link & paste on chrome browser)
https://drive.google.com/file/d/1uwzCpxYCbJ7kzY8gi-cVXqf03otSXOfN/view?usp=sharing
fist create index.php
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id="s_id" onchange="myfun()"><option>--select--</option>
<option value="1">1</option>
<option value="5">5</option>
<option value="8">8</option>
</select>
<div id="showreport1"></div>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
function myfun(){
var s_id=$('#s_id').val();
// alert(s_id);
$.ajax({
type:'POST',
data:{'s_id':s_id},
url:'http://localhost/test/ajax_fetch.php',
success:function(result){
// alert(result)
$('#showreport1').html(result);
}
});
}
</script>
</html>
now create ajax_fetch.php
<table class="table table-striped"><tr><th>Sr No</th><th>name</th><th>hobby</th><th>email</th><th>Image</th> <th>action</th></tr>
<?php $id = $_POST['s_id'];
include "conn.php";
$select = "SELECT * from reg where id ='$id' ";
$data = mysqli_query($conn,$select);
$n = 0;
while ($row = mysqli_fetch_array($data)) { $n++;?>
<tr> <td><?php echo $n ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['hobby']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><img src="upload/<?php echo $row['image'];?>" height="100px" weidth="100px"></td>
<td><a href="delrec.php?id=<?php echo $row['id'] ?>" onclick="return(confirm('are you sure want to delete'))" >delete</a> <a href="edit.php?id=<?php echo $row['id'] ?>">edit</a></td>
</tr>
<?php }
?>
</table>
0 Comments