Search
 
SCRIPT & CODE EXAMPLE
 

PHP

ajax add edit delete records in database using php

function callCrudAction(action,id) {
	$("#loaderIcon").show();
	var queryString;
	switch(action) {
		case "add":
          queryString = 'action='+action+'&txtmessage='+ $("#txtmessage").val();
          break;
		case "edit":
          queryString = 'action='+action+'&message_id='+ id + '&txtmessage='+ $("#txtmessage_"+id).val();
          break;
		case "delete":
			queryString = 'action='+action+'&message_id='+ id;
			break;
     }	 
jQuery.ajax({
  url: "crud_action.php",
  data:queryString,
  type: "POST",
  success:function(data){
  switch(action) {
    case "add":
      $("#comment-list-box").append(data);
      break;
     case "edit":
      $("#message_" + id + " .message-content").html(data);
      $('#frmAdd').show();
      break;
    case "delete":
      $('#message_'+id).fadeOut();
      break;
  }
$("#txtmessage").val('');
$("#loaderIcon").hide();
},
});}
Comment

PREVIOUS NEXT
Code Example
Php :: php console log var_dump 
Php :: print last query laravel 
Php :: tinker lost color 
Php :: var_dump not showing all 
Php :: ubuntu restart php-fpm 
Php :: laravel back button 
Php :: laravel check version 
Php :: get current page url in php 
Php :: laravel random string 
Php :: destroy session codeigniter 3 
Php :: how to get ip address of client using php 
Php :: downgrade php 7.4 to 7.3 mac 
Php :: htaccess post max size 
Php :: get featured image url 
Php :: wordpress get_date 
Php :: ReflectionException: Class MagentoFrameworkAppHttpInterceptor does not exist in 
Php :: remove first letter php 
Php :: php string length 
Php :: show all terms of a custom taxonomy 
Php :: get all values inside session laravel 
Php :: php curl timeout 
Php :: brew switch php version 
Php :: php make query string from array 
Php :: laravel $loop-iteration 
Php :: open php.ini in ubuntu 
Php :: laravel run migration 
Php :: php cut off first x characters 
Php :: get upload error codeigniter 
Php :: gd extension docker php 
Php :: php current file name 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =